Reputation: 2652
I need to change a specific column name in R. I used the following command but it did not change anything.
colnames(mydata[3])<-"newname"
"3" is the column number
Upvotes: 2
Views: 1623
Reputation: 18612
colnames(mydata)[3] <- "newname"
. colnames
is a vector itself, so just move your [3]
outside it.
Upvotes: 2