refactorCategorical {RMixtCompUtilities} | R Documentation |
Rename a categorical value
refactorCategorical(
data,
oldCateg = unique(data),
newCateg = seq_along(oldCateg)
)
data |
matrix/data.frame/vector containing the data |
oldCateg |
vector containing categories to change |
newCateg |
vector containing new categorical values |
Data with new categorical values
Quentin Grimonprez
dat <- c("single", "married", "married", "divorced", "single")
refactorCategorical(dat, c("single", "married", "divorced"), 1:3)