Re: [R] Column renaming

From: Duncan Murdoch <murdoch_at_stats.uwo.ca>
Date: Mon, 05 May 2008 13:01:47 -0400

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

Duncan Murdoch

>
> ?
>
> A semi-related question: how does one get the index of a column by
> name, something along the lines of col.index( X, "sue") ?
>
>
> Chip Barnaby
>
>
> ---------------------------------------------------------
> Chip Barnaby cbarnaby_at_wrightsoft.com
> Vice President of Research
> Wrightsoft Corp. 781-862-8719 x118 voice
> 131 Hartwell Ave 781-861-2058 fax
> Lexington, MA 02421 www.wrightsoft.com
>
> ______________________________________________
> R-help_at_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.



R-help_at_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. Received on Mon 05 May 2008 - 17:18:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 05 May 2008 - 18:30:34 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.

list of date sections of archive