View source: R/summarise_frequency.R
summarise_frequency | R Documentation |
Computes the frequency and relative frequency (or percentage) of factor or character variables in a data frame or vector.
summarise_frequency(
data,
select = NULL,
as_percent = FALSE,
sort_by = NULL,
top_n = Inf
)
data |
A character/factor vector, or a data frame/tibble. |
select |
Optional. One or more variable names to compute frequencies for. If NULL, all factor/character columns are used. |
as_percent |
Logical. If TRUE, relative frequencies are returned as percentages (%). Default is FALSE (proportions). |
sort_by |
Optional. If "N", sorts by frequency; if "group", sorts alphabetically; or "%N" (if as_percent = TRUE). Default is no sorting. |
top_n |
Integer. Show only the top N values |
A tibble with the following columns:
The name of the variable.
The group/category values of the variable.
The count (frequency) of each group.
The proportion or percentage of each group.
summarise_frequency(iris, select = "Species")
summarise_frequency(iris, as_percent = TRUE, sort_by = "N", top_n = 2)
summarise_frequency(data.frame(group = c("A", "A", "B", "C", "A")), as_percent = TRUE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.