rename.vars {gregmisc}R Documentation

Rename variables in a dataframe

Description

Rename a variables in a data frame.

Usage

rename.vars(data, from="", to="", info=TRUE)

Arguments

data dataframe to be modified.
from character vector containing the current name of each variable to be renamed.
to character vector containing the new name of each variable to be renamed.
info boolean value indicating whether to print details of the renaming. Defaults to TRUE.

Value

The updated data frame with variables listed in from renamed to the corresponding element of to.

Author(s)

Code by Don MacQueen macq@llnl.gov. Documentation by Gregory R. Warnes gregory_r_warnes@groton.pfizer.com

See Also

names, colnames, data.frame

Examples

data <- data.frame(x=1:10,y=1:10,z=1:10)
names(data)
data <- rename.vars(data, c("x","y","z"), c("first","second","third"))
names(data)


[Package Contents]