Learn R Programming

RMixtCompUtilities (version 4.1.6)

refactorCategorical: Rename a categorical value

Description

Rename a categorical value

Usage

refactorCategorical(
  data,
  oldCateg = unique(data),
  newCateg = seq_along(oldCateg)
)

Value

Data with new categorical values

Arguments

data

matrix/data.frame/vector containing the data

oldCateg

vector containing categories to change

newCateg

vector containing new categorical values

Author

Quentin Grimonprez

Examples

Run this code
dat <- c("single", "married", "married", "divorced", "single")
refactorCategorical(dat, c("single", "married", "divorced"), 1:3)

Run the code above in your browser using DataLab