Learn R Programming

RMixtCompUtilities (version 4.1.3)

refactorCategorical: Rename a categorical value

Description

Rename a categorical value

Usage

refactorCategorical(
  data,
  oldCateg = unique(data),
  newCateg = 1:length(oldCateg)
)

Arguments

data

matrix/data.frame/vector containing the data

oldCateg

vector containing categories to change

newCateg

vector containing new categorical values

Value

Data with new categorical values

Examples

Run this code
# 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