Skip to content

Commit ec5d52c

Browse files
committed
draft on pause because pipmd_welfare_share_at() does not return the rigth output when popshare = user defined number.
1 parent f3eb60d commit ec5d52c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

vignettes/md_functions.Rmd

+19
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,22 @@ In this vignette, we will explore several typical scenarios in which the pipster
5656
## Case 1: Simple Welfare Analysis and Lorenz Curve
5757

5858
### 1.1 Welfare share at a given population share
59+
```{r popshare}
60+
# Calculate the welfare share at a given population share
61+
selected_popshare <- 0.5
62+
welfare_share_50 <- pipmd_welfare_share_at(welfare = pip_md$welfare,
63+
weight = pip_md$weight,
64+
n = 1,
65+
popshare = selected_popshare)
66+
```
67+
68+
When `complete = FALSE`, the output is a list. The results can be accessed like so:
69+
70+
```{r popshare-results}
71+
# Format the string with the given values
72+
formatted_message <- sprintf("%.0f%% of the population owns %.0f%% of welfare.",
73+
selected_popshare * 100,
74+
welfare_share_50$dist_stats$welfare_share_at[[1]] * 100)
75+
76+
print(formatted_message)
77+
```

0 commit comments

Comments
 (0)