Try this: old.colnames <- colnames(my.439.vars.df) old.colnames[old.colnames=="fksm"] <- "new.name.a" old.colnames[old.colnames=="klmk"] <- "new.name.b"
I don't think it would be too complicated to put this into a function. -Christos -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Anupam Tyagi Sent: Tuesday, September 12, 2006 12:34 AM To: r-help@stat.math.ethz.ch Subject: Re: [R] rename cols For a newcomer who wants to rename variable "fksm" and "klmk" in a dataframe of with 439 variables there is not easy and intuitive solution. That person has to spend a lot of time listing columns and counting columns or doing string searches or using brackets within brackets within brackets to get a simple thing done. Is there a simple function or solution to this in R without using an add-on package? ______________________________________________ R-help@stat.math.ethz.ch 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. ______________________________________________ R-help@stat.math.ethz.ch 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.