rename | R Documentation |
Function to rename a variable in a data frame.
rename(old, new, data)
old |
name of the variable to rename. |
new |
new name of the variable. |
data |
data frame that contains the variable to be renamed. |
The function can be used to rename a variable in a data frame.
A data frame.
Wolfgang Viechtbauer wvb@wvbauer.com
# illustrative dataset
dat <- data.frame(subj=rep(1:4, each=5),
obs = 1:5,
age = rep(c(20,31,27,22), each=5),
stress = c(2,3,1,4,2, 3,3,3,3,3, 1,1,2,6,4, 1,2,1,3,1))
dat
# rename variable age to years
dat <- rename("age", "years", dat)
dat
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.