[R] changing a specific column name

From: pdb <philb_at_philbrierley.com>
Date: Thu, 28 Apr 2011 04:39:19 -0700 (PDT)


Hi,

Can someone please tell me how to change the column name of a specific column. How do I change the name of the column 'Species'?

Thanks in advance

d <- iris

colnames(d)
[1] "Sepal.Length" "Sepal.Width" "Petal.Length" "Petal.Width" "Species"

ind <- which(names(d)=='Species')

ind
[1] 5

colnames(d[ind])
[1] "Species"

colnames(d[ind]) <- 'new name'

colnames(d[ind])
[1] "Species"

--
View this message in context: http://r.789695.n4.nabble.com/changing-a-specific-column-name-tp3480739p3480739.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 28 Apr 2011 - 11:41:40 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 28 Apr 2011 - 12:30:33 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive