rename_with | R Documentation |
Rename multiple columns with the same transformation
rename_with(.df, .fn = NULL, .cols = everything(), ...)
.df |
A data.table or data.frame |
.fn |
Function to transform the names with. |
.cols |
Columns to rename. Defaults to all columns. |
... |
Other parameters to pass to the function |
df <- data.table(
x = 1,
y = 2,
double_x = 2,
double_y = 4
)
df %>%
rename_with(toupper)
df %>%
rename_with(~ toupper(.x))
df %>%
rename_with(~ toupper(.x), .cols = c(x, double_x))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.