Skip to content

Instantly share code, notes, and snippets.

@andilabs
Created August 30, 2013 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andilabs/6389216 to your computer and use it in GitHub Desktop.
Save andilabs/6389216 to your computer and use it in GitHub Desktop.
R rename data frame columns
d <- data.frame(alpha=1:3, beta=4:6, gamma=7:9)
# alpha beta gamma
# 1 4 7
# 2 5 8
# 3 6 9
names(d)
# "alpha" "beta" "gamma"
The simplest way is to use rename() from the plyr package:
rename(d, c("beta"="two", "gamma"="three"))
# alpha two three
# 1 4 7
# 2 5 8
# 3 6 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment