[R] Renaming objects

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Aug 28 15:57:49 CEST 2008


On Thu, 2008-08-28 at 07:39 -0400, stephen sefick wrote:
> names, colnames, rownames <- list of names
> I think it depends on what you are renaming?

Those alter the dimnames of objects that have them, not the names of the
objects themselves.

I think a short answer to the question is no. There is a nice thread on
a similar topic from April this year. In R, do:

RSiteSearch("rename objects")

And the first few hits cover the discussion. Rolf Turner presents his
mv() function in that thread, equivalent to the mv shell command in
Unix.

You could modify Rolf's mv() to accept a vector of objects to rename and
the new names they take. you could probably just pop the body of Rolf's
function in a loop over the number of rename operations, though I
haven't done this myself to check it works so simply...

G

> 
> Stephen
> 
> On Thu, Aug 28, 2008 at 4:03 AM, Williams, Robin
> <robin.williams at metoffice.gov.uk> wrote:
> > Hi,
> >  Is there any quick and easy way to rename a number of objects, without
> > having to rename each one individually and then remove the old one? And
> > if so, is there anything I can do to adjust the associated comments
> > accordingly?
> > Thanks for any help,
> >
> > Robin Williams
> > Met Office summer intern - Health Forecasting
> > robin.williams at metoffice.gov.uk
> >
> >
> >
> >        [[alternative HTML version deleted]]
> >
> > ______________________________________________
> > 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.
> >
> 
> 
> 
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list