recode: Recode a vector.

View source: R/recode.r

recodeR Documentation

Recode a vector.

Description

This utility function will recode values from an original character or factor vector with new values.

Usage

recode(x, from, to, to.class = NULL)

Arguments

x

the vector whose values will be recoded.

from

the old values in x to be recoded.

to

the new values.

to.class

an 'as.' function representing the desired vector type (i.e. as.character, as.numeric, as.logical, as.numeric).

Value

a vector with same length of x with recoded values.

Examples

test <- letters[sample(5, 10, replace=TRUE)]
recode(test, from=letters[1:5], to=paste('Letter', letters[1:5]))

jbryer/likert documentation built on July 29, 2022, 3:42 p.m.