Description Usage Arguments Details Value See Also Examples
Uses an id variable and groupings to calculate proportions in a multiple-choice (checkbox) scenario. I.e., answer proportions sum to more than 100
1 | prop_multi(x, ..., idvar)
|
x |
a tbl() to compute proportions, this can be a grouped tbl() |
... |
Variables to group by. |
idvar |
the response id variable name as *string* (from which distinct respondents are to be computed) |
The function uses the variables names specificed in ..., to conduct a grouping
With a variable name in ..., calculates proportions cases of variable out of the total n unique idvar grouped by the variable. with a variable name in ... and pre grouped data, calc proportions cases of variable out of the total n unique idvar in the pregrouped cathegories grouped by the variable.
A tbl, grouped the same way as x, with the proportions computed out of the distinct respondents. If x is grouped before the ..., the total of the distinct respondents will be calculated out of level of the previous groupings and not from the whole x data.
prop, add_prop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | multi_choice <- tribble(~id, ~choice, ~yr,
1, "A", 2017,
1, "B", 2017,
1, "A", 2018,
2, "A", 2019,
2, "C", 2019,
2, "A", 2017,
3, "A", 2017,
3, "A", 2018)
# disregard the yr variable
multi_choice %>%
prop_multi(choice, idvar = id)
# add the yr variable as a pre-grouping variable and use it as well
multi_choice %>%
group_by(yr) %>%
prop_multi(choice, idvar = "id")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.