powered by
Rename a categorical value
refactorCategorical( data, oldCateg = unique(data), newCateg = seq_along(oldCateg) )
Data with new categorical values
matrix/data.frame/vector containing the data
vector containing categories to change
vector containing new categorical values
Quentin Grimonprez
dat <- c("single", "married", "married", "divorced", "single") refactorCategorical(dat, c("single", "married", "divorced"), 1:3)
Run the code above in your browser using DataLab