fac.recode: Recodes factor 'levels' using values in a vector. The values...

fac.recodeR Documentation

Recodes factor levels using values in a vector. The values in the vector do not have to be unique.

Description

Recodes the levels and values of a factor using each value in the newlevels vector to replace the corresponding value in the vector of levels of the factor.

This function has been superseded by fac.recast, which has extended functionality. Calls to fac.recast that use only the factor and newlevels argument will produce the same results as a call to fa.recode. fac.recode may be deprecated in future versions of dae and is being retained for now to maintain backwards compatibility.

Usage

fac.recode(factor, newlevels, ...)

Arguments

factor

The factor to be recoded.

newlevels

A vector of length levels(factor) containing values to use in the recoding.

...

Further arguments passed to the factor call creating the new factor.

Value

A factor.

Author(s)

Chris Brien

See Also

fac.recast, fac.uselogical, as.numfac and mpone in package dae, factor, relevel.

Examples

## set up a factor with labels
Treats <- factor(rep(1:4, 4), labels=c("A","B","C","D"))
 
## recode "A" and "D" to 1 and "B" and "C" to 2
B <- fac.recode(Treats, c(1,2,2,1), labels = c("a","b"))

dae documentation built on June 22, 2024, 9:07 a.m.