| numeric_to_factor {sjmisc} | R Documentation |
This function converts numeric variables into factors, and uses associated value labels as factor levels.
numeric_to_factor(x, n = 4)
x |
A data frame. |
n |
Numeric, indicating the maximum amount of unique values in |
If x is a labelled vector, associated value labels will be used
as level. Else, the numeric vector is simply coerced using as.factor().
x, with numeric values with a maximum of n unique values
being converted to factors.
library(dplyr) data(efc) efc %>% select(e42dep, e16sex, c12hour, c160age, c172code) %>% numeric_to_factor()