Re: [R] request/suggestion: modified names

From: Gabor Grothendieck <>
Date: Fri 01 Jul 2005 - 09:38:38 EST

On 6/30/05, Ritter, Christian C GSMCIL-GSTMS/2 <> wrote:
> For some time now I use a modified version of names (extract direction) of the following type:
> Names<-
> function (x,filter="^")
> {
> grep(filter,names(x),value=TRUE)
> }
> Request:
> Has anyone already written a version which goes the other way (that is, which allows assignment of the type Names(x,filter)<-...). Naive versions are obvious, but I think something would have to be done to check validity. So if anyone has already done it for me, I would be very happy if you could share it. Such a function would be quite useful when working with large data frames (as I typically do) and need to edit names in a convenient way.
> Suggestion:
> Wouldn't the filter argument make sense in general, that is in "names" and not only in a custom version "Names"?

This is not a direct answer to your question, as stated, but if what is desired is really a method to do ad hoc editing (as opposed to renaming columns on a programmatic basis) then one can use 'fix':

	irish <- head(iris) # test data

At this point a spreadsheet pops up and one can edit the header directly in a GUI. (I am on Windows XP -- not sure if this works on other OSes). Exit the spreadsheet and its done.

This can alternately be done in JGR, a front end to R. Press ctrl-B to access the object browser. Pick out your data frame and a spreadsheet will popup. Right click the column name and choose Rename. mailing list PLEASE do read the posting guide! Received on Fri Jul 01 09:45:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:08 EST