[R] moving functions between namespaces

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Oct 16 18:15:34 CEST 2004


On Sat, 16 Oct 2004, Faber Fedor wrote:

> Hi all,
> 
> I'm a newbie wrt R but that's okay, since I don't do any programming
> in R.  What I do need to do is to administrate the activites of an R
> programmer, so my questions will be related to adminning R as opposed
> to statistcal programming.  I hope that's okay with y'all. :-)
> 
> I've been through most of the docs that I could find (the PDFs,
> StatsRUs, etc.) and I've found the answers to most of my questions,
> but not to an important one: how do I move a function from one
> namespace to another.
> 
> On the chance that I'm not using the right terminlogoy, here's my

I think you mean `workspace', not `namespace', so the explanation was very 
helpful.

> situation: Programmer A has written a function foobar() which resides
> in his namespace /home/progA/.RData.  I want to move foobar(), and
> only foobar(), into the QA enviroment which means replicating foobar()
> inside of /home/qa/.RData.

> I've found that I can use sink() to copy foobar() to a file but 1) I
> haven't found how to read it back in and 2) I figure you guys have a
> more elegant way of doing this.

In /home/progA start R and run save(foobar, file="foobar.rda"). End.

In /home/qa start R and run load("/home/progA/foobar.rda").

If this is more than once off, your programmer should write a package 
containing the useful functions: see `Writing R Extensions'.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list