frelevel | R Documentation |
relevel()
functionThe 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.
frelevel(variable, levels)
variable |
The categorical variable of interest |
levels |
One or more levels of the factor, in the desired order |
A factor of the same length as the initial one.
Adrian Dusa
relevel
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"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.