freq | R Documentation |
This function computes frequency distributions for a specified variable and optionally groups within the data set. It can provide outputs in data frame or LaTeX format, including confidence intervals.
freq(
data,
v,
groups = NULL,
show.na = T,
print.labels = F,
output = "data.frame",
latex.path = NULL,
latex.fn = NULL,
latex.align = NULL,
latex.longtable = F,
latex.caption = NULL,
latex.label = "",
latex.na.rep = "NA",
latex.escape = T,
latex.digits = 2
)
data |
A data frame containing the variables of interest. |
v |
The variable name for which the frequency distribution is calculated. This does not need to be quoted. |
groups |
Optional; a variable name or vectors of variable names to group the results by. This does not need to be quoted. |
show.na |
Logical; if TRUE, NA values are shown. Default is TRUE. Computation always consider NAs to calculate the percentages. |
print.labels |
Logical; if TRUE, labels are printed in the results. Default is FALSE. |
output |
Character; specifies output format, either 'data.frame' or 'latex'. Default is 'data.frame'. |
latex.path |
Character; path to save the LaTeX files. Default is NULL. |
latex.fn |
Character; file name for the LaTeX output. Default is NULL. |
latex.align |
Character; alignment for LaTeX columns. Default is NULL. |
latex.longtable |
Logical; if TRUE, long tables are used for LaTeX output. Default is FALSE. |
latex.caption |
Character; caption for the LaTeX table. Default is NULL. |
latex.label |
Character; label for referencing the LaTeX table. Default is ”. |
latex.na.rep |
Character; representation of NA in LaTeX output. Default is 'NA'. |
latex.escape |
Logical; if TRUE, special LaTeX characters are escaped. Default is TRUE. |
latex.digits |
Integer; number of digits after the decimal point in LaTeX output. Default is 2. |
A data frame or LaTeX table displaying frequency distributions and related statistics.
data(survey)
freq(survey, treat, c(educ, gender))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.