fct_relevel {forcats} | R Documentation |
This is a generalisaton of relevel
that allows you to
move any number of levels to the front.
fct_relevel(f, ...)
f |
A factor. |
... |
Character vector of levels. Any levels not mentioned will be left in existing order, after the explicitly mentioned levels. |
f <- factor(c("a", "b", "c")) fct_relevel(f) fct_relevel(f, "c") fct_relevel(f, "b", "a") # You'll get a warning if the levels don't exist fct_relevel(f, "d")