Learn R Programming

DDIwR (version 0.18)

recodeCharcat: Recode character categorical variables

Description

Recodes a character categorical variables to a numerical categorical variable.

Usage

recodeCharcat(x, ...)

Value

A numeric categorical variable of the same class as the input.

Arguments

x

A character categorical variable

...

Other internal arguments

Author

Adrian Dusa

Details

For this function, a categorical variable is something else than a base factor. It should be an object of class "declared", or an object of class "haven_labelled_spss", with a specific attribute called "labels" that stores the value labels.

Examples

Run this code
x <- declared(
    c(letters[1:5], -91),
    labels = c(Good = "a", Bad = "e", NR = -91),
    na_values = -91
)

recodeCharcat(x)

Run the code above in your browser using DataLab