Summarize categorical variables from a codebook object
Source:R/cb_summarize.r
cb_summarize_categorical.Rdcb_summarize_categorical() generates a frequencies table for all categorical
variables from a codebook object, optionally by group. Variables with value labels,
factors (including ordered factors), and logical variables are treated as categorical.
Usage
cb_summarize_categorical(
cb,
group_by = NULL,
prefixed = TRUE,
detail_missing = missing(group_by),
detail_na_label = "NA",
warn_if_none = TRUE
)Arguments
- cb
An object of class
"li_codebook"as produced bycb_create()or a variant.- group_by
<
tidy-select> Column or columns to group by.- prefixed
Should value labels be prefixed with the corresponding value? e.g.,
TRUEyields"[1] Value One";FALSEyields"Value One".- detail_missing
Include detailed missing value information? Currently supported only when no grouping variables are specified.
- detail_na_label
Label used for
NAvalues whendetail_missingisTRUE.- warn_if_none
Should a warning be issued if there are no categorical variables in
cb?
Value
If there no categorical variables in cb, NULL. Otherwise, a tibble
with columns:
optional grouping column(s) if specified in
group_byname: variable namelabel_stem: optional column containing variable label stems; included ifcbincludes alabel_stemcolumn and at least one categorical variable has a non-missing label stem.label: variable labelis_missing: optional column indicating ifvalueis a missing value. Included ifdetail_missingisTRUE.value: variable valuen: number of observationspct_of_all: proportion of all (non-missing and missing) observationspct_of_valid: for non-missing values, proportion of all non-missing observationspct_of_missing: optional column showing, for missing values, proportion of all missing observations. Included ifdetail_missingisTRUE.