get_n_percent | R Documentation |
Gets count and percentage for factor variables by group. NAs and empty strings are converted to a separate level "Missing" Does a chisquare test if the 'output' argument has a p value column in it. Unless ID variable is specified, the denominator is the number of rows in the dataset.
get_n_percent(
data,
strata,
variable,
name,
output,
id = "",
round = 2,
sort_by_freq = FALSE
)
data |
tibble containing data. Can't be a grouped tibble |
strata |
variable to stratify output by. Needs to be a factor to force to ordering to work. |
variable |
Ideally a factor variable. If not, gets converted to factor anyway. |
name |
string name to put into the row |
output |
The dataframe to append the requested summary to |
id |
Optional. Character vector containing name of variable to use when counting the denominator. Allows the sum of the numerators to be greater than 100 if there is more than one row per denominator variable. |
round |
The number of decimal places to round results to |
sort_by_freq |
TRUE/FALSE for whether to overwrite factor ordering and sort in descending order of total frequency. |
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.