Duncan Murdoch wrote:
On 5/5/2008 10:48 AM, Chip Barnaby wrote:
Dear all,

Is there a less cumbersome way to rename a column by name (as opposed to index) than --

names( X)[ names[ X] == "bob"]<-"sue"

I find this clearer:

X$sue <- X$bob
X$bob <- NULL

...or, essentially the same:

X <- within(X, {sue <-bob; rm(bob)})

Manipulating the names attribute should be more efficient, although not by order of magnitudes, I think.



--
  O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
 c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
(*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])              FAX: (+45) 35327907

______________________________________________
R-help@r-project.org 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.

Reply via email to