count_data | R Documentation |
count_data()
returns the number and proportion of observations for
categorical variables.
count_data(data, ..., na.rm = FALSE, pct = FALSE)
data |
A data frame. |
... |
One or more unquoted (categorical) column names from the data frame, separated by commas. |
na.rm |
A boolean specifying whether missing values (including NaN) should be removed. |
pct |
A boolean indicating whether to calculate percentages instead of
proportions. The default is |
The data frame can be grouped using dplyr::group_by()
so that the number of observations will be calculated within each group
level.
count_data(quote_source, source)
count_data(quote_source, source, sex)
count_data(quote_source, source, sex, na.rm = TRUE)
count_data(quote_source, source, sex, na.rm = TRUE, pct = TRUE)
# Use dplyr::group_by() to calculate proportions within a group
quote_source |>
dplyr::group_by(source) |>
count_data(sex)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.