[R] Column renaming

hadley wickham h.wickham at gmail.com
Mon May 5 19:08:13 CEST 2008


On Mon, May 5, 2008 at 10:54 AM, Chip Barnaby <cbarnaby at wrightsoft.com> wrote:
> Yes, someone else pointed out my typo, sorry.
>
>  My issue here is that referring to columns by index is risky.  Hard-coded
> indices will be buried in code and there will be trouble if (when) the data
> organization changes.  So I am trying to learn how to work with names, but
> the language does not seem to allow that approach without some awkwardness.
> I guess I could write some helper functions.

There's the rename function in the reshape package:

library(reshape)
X <- rename(X, c("bob" = "sue")

Hadley


-- 
http://had.co.nz/



More information about the R-help mailing list