frelevel {admisc}R Documentation

Modified relevel() function

Description

The base function relevel() accepts a single argument "ref", which can only be a scalar and not a vector of values. frelevel() accepts more (even all) levels and reorders them.

Usage

frelevel(variable, levels)

Arguments

variable

The categorical variable of interest

levels

One or more levels of the factor, in the desired order

Value

A factor of the same length as the initial one.

Author(s)

Adrian Dusa

See Also

relevel

Examples

words <- c("ini", "mini", "miny", "moe")
variable <- factor(words, levels = words)

# modify the order of the levels, keeping the order of the values
frelevel(variable, c("moe", "ini", "miny", "mini"))


[Package admisc version 0.35 Index]