rename {poorman}R Documentation

Rename columns

Description

rename() changes the names of individual variables using new_name = old_name syntax. rename_with() renames columns using a function.

Usage

rename(.data, ...)

rename_with(.data, .fn, .cols = everything(), ...)

Arguments

.data

A data.frame

...

For rename(): comma separated key-value pairs in the form of new_name = old_name to rename selected variables.

For rename_with(): additional arguments passed onto .fn.

.fn

A ⁠function()⁠ used to transform the selected .cols. Should return a character vector the same length as the input.

.cols

Columns to rename; defaults to all columns.

Value

A data.frame with the following properties:

Examples

rename(mtcars, MilesPerGallon = mpg)
rename(mtcars, Cylinders = cyl, Gears = gear)
mtcars %>% rename(MilesPerGallon = mpg)

rename_with(mtcars, toupper)
rename_with(mtcars, toupper, starts_with("c"))


[Package poorman version 0.2.7 Index]