Standard Frequency Tables in R
frequencies.Rd
Standard Frequency Tables in R
Usage
frequencies(
x = NULL,
weights = NULL,
n.classes = NULL,
lower.limit = NULL,
upper.limit = NULL,
time.breaks = NULL,
svy.design = NULL,
sort.decreasing = NULL,
tidy.breaks = FALSE,
na.count = TRUE,
n.digits = 2,
show.totals = TRUE,
show.percent = TRUE,
use.thousands.mark = FALSE,
as.markdown = FALSE,
as.categorical = FALSE,
compare.valids = FALSE,
show.relative = TRUE,
show.cumulative = FALSE,
show.rel.cumulative = FALSE,
show.frequencies = TRUE
)
Arguments
- x
Vector or data.frame. A numeric or categorical variable of any type.
- weights
Numeric. Weights for aggregating the categories in x. It should have the same length of x.
- n.classes
Integer or numeric. If a single integer, it represents the number of classes for the numeric variable. If a vector of numeric values, it will represent the desired break points for the classes. Defaults to the number of classes determined by the Herbert Sturges algorithm.
- lower.limit
Numeric. Lower classes limit. Along with n.classes, it determines the bins of a distribution for continuous variables. Defaults to the minimum value of the numeric vector.
- upper.limit
Numeric. Lower classes limit. Along with n.classes, it determines the bins of a distribution for continuous variables. Defaults to the maximum value of the numeric vector.
- time.breaks
Character or integer. Specifies the aggregation class for date-time variables: "secs", "mins", "hours", "days", "weeks", "months","years", "DSTdays" or "quarters". If an integer it specifies an arbitrary number of classes for all the observations.
- svy.design
survey.design object. A survey design object from survey::package.
- sort.decreasing
NULL or logical. sort frequencies decreasingly, increasingly according to frequency counts. The default, NULL, sorts frequencies according with the classes.
- tidy.breaks
Logical. Uses the default classes for histograms, allowing the frequency table of numeric values to match the default graphical bins for an histogram. It overrides the value for n.classes.
- na.count
Logical. include NA values as part of the classes to be counted. If the vector has no missing values it will report 0 occurrences when TRUE is selected.
- n.digits
Integer. number of decimal places to display for percentage frequencies. The number of decimals shown for relative frequencies is n.digits + 2.
- show.totals
Logical. Show the sum of frequencies and relative/percentage frequencies.
- show.percent
Logical. Show relative frequencies as percentage frequencies. Default is TRUE.
- use.thousands.mark
Logical. Show the thousands mark for numeric columns. Warning: numeric variables will be stored as character.
- as.markdown
Logical. Return the frequency table in RMarkdown format, uses the pander:: package.
- as.categorical
Logical. If TRUE, it will display each integer value as a different category. If FALSE, it will aggregate integer values into classes for unique values greater than 15. Useful for displaying variables with several categories, such as Default is FALSE.
- compare.valids
Logical. Show or hide an additional column for each column type to compare valid vs. NA values, default is FALSE. It overrides selected option for na.count argument.
- show.relative
Logical. Show or hide the column for relative frequencies, default is TRUE.
- show.cumulative
Logical. Show or hide the column for cumulative frequencies, default is FALSE
- show.rel.cumulative
Logical. Show or hide the column for relative cumulative frequencies, default is FALSE.
- show.frequencies
Logical. Show or hide the column for counts per class, default is TRUE.
Examples
frequencies(x = airquality$Ozone)
#> classes freqs relative_freqs
#> 1 [ 1.0, 21.9) 41 26.80
#> 2 [ 21.9, 42.8) 31 20.26
#> 3 [ 42.8, 63.6) 15 9.80
#> 4 [ 63.6, 84.5) 15 9.80
#> 5 [ 84.5,105.4) 7 4.58
#> 6 [105.4,126.2) 5 3.27
#> 7 [126.2,147.1) 1 0.65
#> 8 [147.1,168.0] 1 0.65
#> 9 NA VALUES 37 24.18
#> 10 TOTAL 153 100.00