[R] Package dependencies in building R packages
Hadley Wickham
h.wickham at gmail.com
Tue Dec 31 16:20:42 CET 2013
> 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.
3) Use namespaces: in your DESCRIPTION add `Import: MASS`, and in your
NAMESPACE add `importFrom(MASS,mvrnorm)`
Then you can access mvrnorm from your package, but it won't be made
available to the user who loads your package, and it won't pull in any
other functions from MASS or survival either.
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list