rename_with: Rename multiple columns

View source: R/rename_with.R

rename_withR Documentation

Rename multiple columns

Description

Rename multiple columns with the same transformation

Usage

rename_with(.df, .fn = NULL, .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

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))

tidytable documentation built on Sept. 11, 2024, 8:05 p.m.