cat_desc_stats: Compute absolute and relative frequencies.

View source: R/descriptives.R

cat_desc_statsR Documentation

Compute absolute and relative frequencies.

Description

cat_desc_stats computes absolute and relative frequencies for categorical data with a number of formatting options.

Usage

cat_desc_stats(
  source = NULL,
  separator = " ",
  return_level = TRUE,
  ndigit = 0,
  groupvar = NULL,
  singleline = FALSE,
  percent = TRUE,
  prettynum = FALSE,
  .german = FALSE,
  quelle = NULL
)

Arguments

source

Data for computation. Previously "quelle".

separator

delimiter between results per level, preset as ' '.

return_level

Should levels be reported?

ndigit

Digits for rounding of relative frequencies.

groupvar

Optional grouping factor.

singleline

Put all group levels in a single line?

percent

Logical, add percent-symbol after relative frequencies?

prettynum

logical, apply prettyNum to results?

.german

logical, should "." and "," be used as bigmark and decimal? Sets prettynum to TRUE.

quelle

deprecated, retained for compatibility, use 'source' instead.

Value

Structure depends on parameter return_level: if FALSE than a tibble with descriptives, otherwise a list with two tibbles with levels of factor and descriptives. If parameter singleline is FALSE (default), results for each factor level is reported in a separate line, otherwise they are pasted. Number of columns for result tibbles is one or number of levels of the additional grouping variable.

Examples

cat_desc_stats(mtcars$gear)
cat_desc_stats(mtcars$gear, return_level = FALSE)
cat_desc_stats(mtcars$gear, groupvar = mtcars$am)
cat_desc_stats(mtcars$gear, groupvar = mtcars$am, singleline = TRUE)

wrappedtools documentation built on Sept. 1, 2022, 5:06 p.m.