[R] about colnames

=?gb2312?B?w8/QwA==?= xmeng at capitalbio.com
Tue Dec 21 10:45:25 CET 2004


Hello sir:
If there's a data frame(with name "df"):
a  b  c d  e   f 
1 10 12 20 30  100
2 3  15 16 40  200
..

If I wanna change the last 3 colunm names"d" "e" "f" respectively into "x" "y" "z"respectively,the following is what I do:
colnames(df[4:6])<-c("x","y","z")
But no change to the colnames of df.



And if I wanna change all the colnames:
colnames(df)<-letters[1:6]
All the colnames have been changed.

So I wanna know the reason,and how to change the last 3 colnames of df.

Thanks a lot!




More information about the R-help mailing list