[R] Updating R-code in own package

Duncan Murdoch murdoch at stats.uwo.ca
Fri Sep 18 16:42:32 CEST 2009


On 9/18/2009 9:05 AM, Steve Lianoglou wrote:
> Hi,
> 
> On Sep 18, 2009, at 8:31 AM, Katrine Damgaard wrote:
> 
>> Hey everybody!
>> We have created our own package, and need to do some corrections in  
>> the R-code of one of the function included in the package.
>> How can I do that. I have read a manual how to create an R package,  
>> but I can't find anything about updating R-code in the package.
> 
> I'm pretty sure the only "correct" thing to do is just fix the code in  
> your package's source tree then reinstall the package wholesale to  
> replace the bad code with the fixed code.

Yes, that's the simplest way to do it.  It also usually works for 
testing to just source the file containing the fix, to get a new copy in 
the global environment.  This can sometimes fail if the function refers 
to other functions in the package that are not visible in the global 
environment, due to NAMESPACE hiding.  It's possible to manipulate the 
environment of the sourced function (and it's even possible to place it 
into the right place so it just works), but those usually aren't worth 
the trouble.

Duncan Murdoch




More information about the R-help mailing list