rename_with.: Rename multiple columns

Description Usage Arguments Examples

View source: R/rename_with.R

Description

Rename multiple columns with the same transformation

Usage

1
rename_with.(.df, .fn, .cols = everything(), ...)

Arguments

.df

A data.table or data.frame

.fn

Function to transform the names with.

.cols

Columns to rename. Defaults to all columns. tidyselect compatible.

...

Other parameters to pass to the function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
test_df <- data.table(
  x = 1,
  y = 2,
  double_x = 2,
  double_y = 4
)

test_df %>%
  rename_with.(toupper)

test_df %>%
  rename_with.(~ toupper(.x))

test_df %>%
  rename_with.(~ toupper(.x), .cols = c(x, double_x))

mtfairbanks/gdt documentation built on May 4, 2021, 9:44 a.m.