Skip to content

data frame column name change

3 messages · eric, Jorge Ivan Velez, Pete Brecknock

#
How do I change the name of one column in a data frame ? Suppose I have a
data frame x with 5 columns. If the names were date, col1, col2, col3, col4
and I wanted to simply change the name of date, what would the command be ?
I tried the following and it didn't seem to work :

names(x[1]) <- "newname"

Thanks in advance for the comments