Convenience function for levelling, labelling and referencing multiple factors in one step. Works with piping. The order of effects is:
Set as factor (fct_infreq setting levels based on frequency, most common is reference)
Set reference levels
Set levels manually
Set labels
The list can be non-complete if no modifications should be passed to the remaining variables
Arguments
- data
dataframe
- vars
Vector of variables that should be factorized. The names from the lists "reference", "labels" and "levels" are automatically registered.
- num.vars
vector of variables with pseudonumeric ordering
- reference
List of variables with the reference level (e.g. list("v1" = "a"))
- levels
List of variables with the corresponding levels (e.g. list("v1" = "c("a","b","c","d","e")))
- labels
List of variables with the corresponding labels (e.g. list("v3" = c("e" = "epsilon", "d" = "delta")))
- lab_to_lev
Whether changing labels should change levels if these are not specified (defaults to TRUE)
- reverse
Whether the levels should be reversed (default is FALSE)
- auto.format
whether no/yes and 0/1 should be autoformatted with no as reference
- dt
whether the data frame should be returned as data.table (default = F)
