Re: [R] rename cols

From: Anupam Tyagi <AnupTyagi_at_yahoo.com>
Date: Tue 12 Sep 2006 - 06:44:03 GMT

Christos Hatzis <christos <at> nuverabio.com> writes:

>
> 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"

For a newcomer, it will be useful to have a function like this in the base R: that can take a list of old.names and new.names, and do the assignment. It is far more efficient to have functions that are shared via the R distribution, than having to write own functions for carrying out basic data management tasks, and simple routinely used statistical procedures. Most users would rather spend time on thinking about the substantive work, instead of figuring out how to program---this may be specially true for new users. This way the functions used will also be more efficient and better designed than the typical new user.



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. Received on Tue Sep 12 16:54:42 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 12 Sep 2006 - 12:30: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.