calc_perc | R Documentation |
Compute the percentage based on one or multiple variables.
calc_perc(df, grp_var, main_var = NULL)
df |
A single data.frame |
grp_var |
The grouping variable(s) based on which the percentages will be computed |
main_var |
An optional variable, when provided, will be utilized to compute the percentage for each of its own levels |
A data.frame summarizing the counts and percentages within groups. The output is arranged in descending order of counts within each group.
#without main_var
calc_perc(mtcars,grp_var = c(cyl,vs))
#main_var within grp_var
calc_perc(mtcars,grp_var = c(cyl,vs),main_var = vs)
#main_var not within grp_var
calc_perc(mtcars,grp_var = c(cyl),main_var = vs)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.