Column renaming
I agree there. I believe the same effect can be achieved with 'transform'. transform(X, sue = bob, bob = NULL) Perhaps there are performance reasons for using the names() <- value approach for very large data.frames?
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 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.