Try colnames(df)[4:6] <- c("x","y","z")
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of [EMAIL PROTECTED] Sent: 21 December 2004 09:45 To: [EMAIL PROTECTED] Subject: [R] about colnames 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! ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html ______________________________________________ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html