[R] Change the names of a dataframe

From: Jun Shen <jun.shen.ut_at_gmail.com>
Date: Tue, 03 May 2011 15:43:23 -0500


Dear list,

This may sound silly. What is the right way to change the names of a dataframe? Let's say I have this data frame (dose) with four columns with names "ID", "DOSE", "TIME" "CMT". I want to change "DOSE" to "AMT". So I did

names(dose[2])<-'AMT'

But nothing happened. The name of the second column is still "DOSE".

Only this works

names(dose)[2]<-'AMT'

I wonder what is wrong with the first method. Thanks.

Jun

        [[alternative HTML version deleted]]



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 05 May 2011 - 06:25:04 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 05 May 2011 - 07:00:05 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