Learn R Programming

doBy (version 3.9)

recodevar: recode levels of variable

Description

Recodes a variable with levels, say '1','2' to a variable with levels, say 'a', 'b'

Usage

recodevar(var, src, tgt)

Arguments

var
The variable to be recoded
src
The source levels: the present levels of var
tgt
The target levels: the new levels of var

Value

  • A new variable

Examples

Run this code
x <- c("dec","jan","feb","mar","apr","may")
 src1 <- list(c("dec","jan","feb"), c("mar","apr","may"))
 tgt1 <- list("winter","spring")
 recodevar(x,src=src1,tgt=tgt1)

Run the code above in your browser using DataLab