Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

rename

Modify names by name, not position.


Description

Modify names by name, not position.

Usage

rename(x, replace, warn_missing = TRUE, warn_duplicated = TRUE)

Arguments

x

named object to modify

replace

named character vector, with new names as values, and old names as names.

warn_missing

print a message if any of the old names are not actually present in x.

warn_duplicated

print a message if any name appears more than once in x after the operation. Note: x is not altered: To save the result, you need to copy the returned data into a variable.

Examples

x <- c("a" = 1, "b" = 2, d = 3, 4)
# Rename column d to "c", updating the variable "x" with the result
x <- rename(x, replace = c("d" = "c"))
x
# Rename column "disp" to "displacement"
rename(mtcars, c("disp" = "displacement"))

plyr

Tools for Splitting, Applying and Combining Data

v1.8.6
MIT + file LICENSE
Authors
Hadley Wickham [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.