Rename multiple columns with the same transformation
rename_with(.df, .fn = NULL, .cols = everything(), ...)
df <- data.table(
x = 1,
y = 2,
double_x = 2,
double_y = 4
)
df %>%
rename_with(toupper)
#> # A tidytable: 1 × 4
#> X Y DOUBLE_X DOUBLE_Y
#> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 2 4
df %>%
rename_with(~ toupper(.x))
#> # A tidytable: 1 × 4
#> X Y DOUBLE_X DOUBLE_Y
#> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 2 4
df %>%
rename_with(~ toupper(.x), .cols = c(x, double_x))
#> # A tidytable: 1 × 4
#> X y DOUBLE_X double_y
#> <dbl> <dbl> <dbl> <dbl>
#> 1 1 2 2 4