Extracts categorical variables from a data frame.
Usage
getCatVars(data, Ordinal = TRUE, DataFrame = lifecycle::deprecated())See also
getNumVars() and getBinaryVars() for the other partitions.
Examples
data(SampleData)
data(SampleVariableTypes)
Labelled <- RevalueData(SampleData, SampleVariableTypes)$RevaluedData
# Every factor in the frame
getCatVars(Labelled)
#> [1] "Diagnosis" "sex" "Genotype"
# `Ordinal = FALSE` drops ordered factors, which is what you want when the
# ordered variables are going to be analyzed on their numeric scale instead.
getCatVars(Labelled, Ordinal = FALSE)
#> [1] "Diagnosis" "sex" "Genotype"
# Only meaningful after RevalueData(): in the raw extract `sex` is still a
# bare 0/1 numeric column and is not detected as categorical.
getCatVars(SampleData)
#> character(0)
