relocate | R Documentation |
Move a column or columns to a new position
relocate(.df, ..., .before = NULL, .after = NULL)
.df |
A data.frame or data.table |
... |
A selection of columns to move. |
.before |
Column to move selection before |
.after |
Column to move selection after |
df <- data.table(
a = 1:3,
b = 1:3,
c = c("a", "a", "b"),
d = c("a", "a", "b")
)
df %>%
relocate(c, .before = b)
df %>%
relocate(a, b, .after = c)
df %>%
relocate(where(is.numeric), .after = c)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.