count_data {tidystats} | R Documentation |
Count the number of observations
Description
count_data()
returns the number and proportion of observations for
categorical variables.
Usage
count_data(data, ..., na.rm = FALSE, pct = FALSE)
Arguments
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 |
Details
The data frame can be grouped using dplyr::group_by()
so that the number of observations will be calculated within each group
level.
Examples
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)
[Package tidystats version 0.6.2 Index]