freq | R Documentation |
Prints a frequency table for the specified variable.
freq(
df,
var = NA,
plot = interactive(),
sort = TRUE,
markdown = !interactive(),
wt = NULL,
na.rm = FALSE
)
df |
A data.frame (optionally, you can pass a variable as the first argument.) |
var |
a variable in the associated data.frame |
plot |
if TRUE prints bar chart of results. Default is TRUE if interactive(), otherwise FALSE |
sort |
If TRUE (default), sort output in descending order of n. If FALSE, sort output in ascending order of levels |
markdown |
if false, formats table for Rmarkdown/Quarto inclusion. |
wt |
a variable representing weights |
na.rm |
if FALSE (default) NAs are included in frequency list. If TRUE, NA are removed (but reported separately) |
This function constructs a frequency table for the specified variable. It expects a data.frame as the first argument and an (unquoted) variable as the second argument. It will thus fit into a tidyverse pipeline. Alternatively, for convenience, a vector can be passed as first argument and the var (second) argument left blank.
The console printed table is highly customizable using session, project, or global options. The following options are currently implemented and can be set by calling 'options()' either interactively or by including in your .Rprofile.
- simplefreqs.inner_table_padding
- simplefreqs.table_symbol
- simplefreqs.row_divider_symbol
- simplefreqs.print_table_symbol
- simplefreqs.print_table_total_row
- simplefreqs.print_table_metadata
- simplefreqs.print_header_divider
- simplefreqs.big_mark
- simplefreqs.decimal_digits
data.frame containing frequencies.
freq(iris, Species, markdown = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.