[R] rename cols
AnupTyagi at yahoo.com
Tue Sep 12 08:44:03 CEST 2006
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.
More information about the R-help