Function to show frequencies in a manner similar to what SPSS' "FREQUENCIES"
command does. Note that frequency
is an alias for freq
.
freq(
vector,
digits = 1,
nsmall = 1,
transposed = FALSE,
round = 1,
plot = FALSE,
plotTheme = ggplot2::theme_bw()
)
# S3 method for freq
print(
x,
digits = x$input$digits,
nsmall = x$input$nsmall,
transposed = x$input$transposed,
...
)
# S3 method for freq
pander(x, ...)
frequencies(
...,
digits = 1,
nsmall = 1,
transposed = FALSE,
round = 1,
plot = FALSE,
plotTheme = ggplot2::theme_bw()
)
# S3 method for frequencies
print(x, ...)
# S3 method for frequencies
pander(x, prefix = "###", ...)
A vector of values to compute frequencies for.
Minimum number of significant digits to show in result.
Minimum number of digits after the decimal point to show in the result.
Whether to transpose the results when printing them (this can be useful for blind users).
Number of digits to round the results to (can be used in conjunction with digits to determine format of results).
If true, a histogram is shown of the variable.
The ggplot2 theme to use.
The freq
or frequencies
object to print.
For frequencies
, the variables of which to provide
frequencies; for the print
methods, additional arguments are passed on
to the print
function.
The prefix to use when printing frequencies
, to easily prepend
Markdown headers.
An object with several elements, the most notable of which is:
A dataframe with the frequencies
For frequencies
, these objects are in a list of their own.
### Create factor vector
ourFactor <- factor(mtcars$gear, levels=c(3,4,5),
labels=c("three", "four", "five"));
### Add some missing values
factorWithMissings <- ourFactor;
factorWithMissings[10] <- factorWithMissings[20] <- NA;
### Show frequencies
freq(ourFactor);
#> Frequencies Perc.Total Perc.Valid Cumulative
#> three 15 46.9 46.9 46.9
#> four 12 37.5 37.5 84.4
#> five 5 15.6 15.6 100.0
#> Total valid 32 100.0 100.0
freq(factorWithMissings);
#> Frequencies Perc.Total Perc.Valid Cumulative
#> three 15 46.9 50.0 50.0
#> four 10 31.2 33.3 83.3
#> five 5 15.6 16.7 100.0
#> Total valid 30 93.8 100.0
#> NA (missing) 2 6.2
#> Total 32 100.0
### ... Or for all of them at one
frequencies(ourFactor, factorWithMissings);
#> ### Frequencies for 'ourFactor'
#>
#> Frequencies Perc.Total Perc.Valid Cumulative
#> three 15 46.9 46.9 46.9
#> four 12 37.5 37.5 84.4
#> five 5 15.6 15.6 100.0
#> Total valid 32 100.0 100.0
#>
#> ### Frequencies for 'factorWithMissings'
#>
#> Frequencies Perc.Total Perc.Valid Cumulative
#> three 15 46.9 50.0 50.0
#> four 10 31.2 33.3 83.3
#> five 5 15.6 16.7 100.0
#> Total valid 30 93.8 100.0
#> NA (missing) 2 6.2
#> Total 32 100.0
#>