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 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. Any advice?
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 myI 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
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 > 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. > > Any advice?The term "namespace" now means something other than the way you use it but that's not important. The simple way to do this is to have Programmer A start up R in /home/progA and save a copy of the function foobar to a file. save(foobar, file = "/home/qa/foobar.rda") (Depending on the size of the file Programmer A may wish to add the optional argument compress = TRUE in that call.) Now start R in /home/qa and load the saved copy load("/home/qa/foobar.rda") then exit R. I'm tempted to write more about variations on this mechanism but I think I'll just stay with the simple answer.