View source: R/data_manip_utils.R
relevel_columns | R Documentation |
This is a shortcut for calling forcats::fct_relevel()
on multiple
columns of a data frame.
relevel_columns(df, ...)
df |
The data frame in which to re-level some factor columns. |
... |
Additional arguments control the re-leveling of factors.
The name of each argument indicates the column of |
df
, with the specified factor columns re-leveled
according to the provided specifications.
x <- data.frame(a = letters[1:2], b = LETTERS[1:6]) sapply(x, levels) x2 <- relevel_columns(x, a = c("b", "a"), b = list("B", "A", after = 2)) sapply(x2, levels)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.