[R] Package dependencies in building R packages

Duncan Murdoch murdoch.duncan at gmail.com
Mon Dec 30 21:13:29 CET 2013


On 13-12-30 2:01 PM, Axel Urbiz wrote:
> Thanks for your kind response Duncan. To be more specific, I'm using the
> function mvrnorm from MASS. The issue is that MASS depends on survival
> and I have a function in my package named tt() which conflicts with a
> function in survival of the same name. I can think of 2 alternatives
> solutions to my problem, but I'm to an expert:
>
> 1) Copy mvrnorm into my package, which I thought was not a good idea
> 2) Rename my tt() function to something else in my package, but this is
> painful as I have it all over the place in other functions.
>
> Any suggestions would be much appreciated.

I would simply import MASS::mvrnorm in your NAMESPACE file.  Then the tt 
function in survival won't be visible in your package and won't become 
visible to users because of you, so most users won't be affected by the 
conflict.  (In fact, I think MASS only "Suggests" survival, so even if 
you attach MASS, you won't automatically attach survival.)

Of course, some users may attach both your package and the survival 
package, and then the name clash will inconvenience them.  If your 
package is new, I'd choose a different name for tt() to avoid this.  If 
you have already published it using the name tt(), then renaming it will 
possibly inconvenience more people than dealing with the name clash 
does, so I'd just document it in the ?tt help page.

Duncan Murdoch



More information about the R-help mailing list