Modified relevel() function
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.
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
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"))
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.