freq

0th

Percentile

Frequency Tables for Factors and Other Discrete Data

Displays weighted or unweighted frequencies including counts and proportions.

Keywords
univar , classes category
Usage
freq(x, round.digits=2, style="simple", justify="right", plain.ascii=TRUE, file=NA, append=FALSE, escape.pipe=FALSE, weights=NA, rescale.weights=FALSE, ...)
Arguments
x
Vector of discrete (categorical) data.
round.digits
Number of sig. digits to keep in output. Defaults to 2.
style
Style of pander tables, one of “simple” (default), “grid” and “rmarkdown”.
justify
pander argument. Defaults to "right".
plain.ascii
pander argument; when results are displayed in console, this avoids having markdown markup characters in the tables. Defaults to TRUE, except when style='rmarkdown' (see Details).
file
File name to write output to. Defaults to NA. To append output to an existing text file, use append=TRUE.
append
When “file” argument is supplied, this indicates whether to append output to existing file (TRUE) or to overwrite any existing file (FALSE, default). If TRUE and no file exists, a new file will be created.
escape.pipe
Only useful when style='grid' and file argument is not NA, in which case it will escape the pipe character (|) to allow Pandoc to correctly convert multiline cells.
weights
Vector of weights, having same length as x
rescale.weights
Logical parameter. When TRUE, the function makes the sum of weights equal to the length of x, so that the total N remains unchanged. FALSE by default.
...
Additional arguments passed to pander.
Details

The default plain.ascii=TRUE option is there to make results appear clean in the console, but creates problems when generating markdown documents. For this reason, whenever style='rmarkdown', the option is set to FALSE, unless plain.ascii=TRUE is stated explicitly. On the other hand, with style='grid', if the intent is to produce markdown text, then the user needs to explicitly set plain.ascii=FALSE.

Value

matrix with attributes used by summarytool's print method.

References

https://github.com/dcomtois/summarytools

Aliases
  • freq
Examples
data(tobacco)
freq(tobacco$gender)
freq(tobacco$gender, style="rmarkdown")
with(tobacco, by(smoker, gender, freq))
Documentation reproduced from package summarytools, version 0.6.5, License: GPL-2

Community examples

Looks like there are no examples yet.