This is a convenience function to convert the expected set of numeric
category variables to factors. It's basically a wrapper for
df_factor_var
.
label_categories(df, categories = c("R3", "sex", "res"), ...)
df | data frame: Input data frame |
---|---|
categories | character: vector of variable names to convert to factor (if present) |
... | additional arguments passed to |
Salic Function Reference: salic
Other functions for working with category variables: df_factor_var
,
factor_var
, recode_agecat
library(dplyr) data(history) x <- label_categories(history, suppress_check = FALSE)#> # A tibble: 5 x 3 #> new old n #> <fct> <int> <int> #> 1 Carry 1 10476 #> 2 Renew 2 21134 #> 3 Reactivate 3 8941 #> 4 Recruit 4 13534 #> 5 <NA> NA 37821 #> #> # A tibble: 3 x 3 #> new old n #> <fct> <int> <int> #> 1 Male 1 71930 #> 2 Female 2 18474 #> 3 <NA> NA 1502 #> #> # A tibble: 2 x 3 #> new old n #> <fct> <int> <int> #> 1 Resident 1 71345 #> 2 Nonresident 0 20561 #>