Learn R Programming

sdcMicro (version 2.0.4)

globalRecode: Global Recoding

Description

Global recoding

Usage

globalRecode(x, breaks, labels)

Arguments

x
vector for recoding
breaks
either a numeric vector of cut points or number giving the number of intervals which x is to be cut into.
labels
labels for the levels of the resulting category. By default, labels are constructed using "(a,b]" interval notation. If labels = FALSE, simple integer codes are returned instead of a factor.

Value

  • A factor is returned, unless labels = FALSE which results in the mere integer level codes.

Details

If a labels parameter is specified, its values are used to name the factor levels. If none is specified, the factor level labels are constructed.

See Also

cut

Examples

Run this code
data(free1)
free1[, "AGE"] <- globalRecode(free1[,"AGE"], breaks=c(1,9,19,29,39,49,59,69,100), labels=1:8)

Run the code above in your browser using DataLab