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

rename-au

Rename


Description

Rename an object

Usage

rename(x, replace)

Arguments

x

object to be renamed

replace

named vector specifying new names

Details

The rename function provide an easy way to rename the columns of a data.frame or the items in a list.

Author(s)

Hadley Wickham <h.wickham@gmail.com>

Examples

rename(mtcars, c(wt = "weight", cyl = "cylinders"))
a <- list(a = 1, b = 2, c = 3)
rename(a, c(b = "a", c = "b", a="c")) 

# Example supplied by Timothy Bates
names <- c("john", "tim", "andy")
ages <- c(50, 46, 25)
mydata <- data.frame(names,ages)
names(mydata) #-> "name",  "ages"

# lets change "ages" to singular.
# nb: The operation is not done in place, so you need to set your 
# data to that returned from rename

mydata <- rename(mydata, c(ages="age"))
names(mydata) #-> "name",  "age"

reshape

Flexibly Reshape Data

v0.8.8
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.