factor2numeric {RTCA}R Documentation

FACTOR UNITILITIES

Description

The functions implement easy interface to certain tasks of factor. See datails for explaination

Usage

factor2numeric(x)
relevels(x, refs)

Arguments

x

A vector of factor

refs

A vector of character, reference vector to give the orderof levels

Details

relevels re-arrange the order of levels by the given character refs. Alternatively user could use factor(...,levels=refs) to achieve a similar effect, however the relevels enables also partial list. The missing levels in refs will be ordered to the last.

factor2numeric converts factor of numerics into their numeric form.

Value

A vector of factor

Author(s)

Jitao David Zhang jitao_david.zhang@roche.com

Examples

## factor2numeric
numFac <- factor(c(3.5, 2.5, 2.5,3.5, 1))
numFac
levels(numFac)

factor2numeric(numFac)
class(factor2numeric(numFac))

## relevels
relevels(numFac, c("3.5", "1", "2.5"))
relevels(numFac, c("3.5", "2.5"))

[Package RTCA version 1.38.0 Index]