reorderFactor: reorderFactor

Description Usage Arguments Value Author(s) See Also Examples

View source: R/misc.R

Description

reorder the factor levels in a factor

Usage

1
reorderFactor(x, newLevels)

Arguments

x

factor to reorder

newLevels

character vector: levels in new order

Value

factor with levels corresponding to newLevels

Author(s)

Thomas Wutzler

See Also

seqRange, twMisc

Examples

1
2
3
4
5
6
7
x <- as.factor(sample(c("low","medium","high"),10,replace=TRUE) )
x
as.integer(x)
y <- reorderFactor(x,c("low","medium","high"))
y
as.integer(y)
all(x == y)

twMisc documentation built on May 2, 2019, 6:11 p.m.