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