Description Usage Arguments Value Examples
calc_shares
makes it easy to divide values by some denominator within the same long-shaped data frame. For example, it works well for a table of population groups for multiple locations where you want to divide population counts by some total population. It optionally handles dividing margins of error. Denote locations or other groupings by using a grouped data frame, passing bare column names to ...
, or both.
1 2 3 4 5 6 7 8 9 10 |
.data |
A data frame |
... |
Optional; bare column names to be used for groupings. |
group |
Bare column name where groups are given–that is, the denominator value should be found in this column |
denom |
String; denominator to filter from |
value |
Bare column name of values. Replaces |
moe |
Bare column name of margins of error; if supplied, MOE of shares will be included in output |
digits |
Number of digits to round to; defaults to 3. |
estimate |
Soft deprecated; use |
A tibble/data frame with shares (and optionally MOE of shares) of subgroup values within a denominator group. Shares given for denominator group will be blank.
1 2 3 4 5 6 7 8 | edu %>%
dplyr::group_by(name) %>%
calc_shares(group = variable, denom = "age25plus",
value = estimate, moe = moe)
race_pops %>%
calc_shares(name, group = variable, denom = "total",
value = estimate, moe = moe)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.