[R] Package dependencies in building R packages

Paul Gilbert pgilbert902 at gmail.com
Tue Dec 31 17:57:32 CET 2013


The responses to this seem to be assuming that you want users to have 
access to your tt() function, that is, you export it. Just in case the 
really simple case has been overlooked: if you are only using this 
function internally in your package there should be no problem. Your 
package's namespace ensures that your package's functions find your 
tt(), and if you do not export it then user references to tt() will not 
find your version.

As others have pointed out, if you want users to have access to your 
tt() and they also need access to survival's tt(), then there is a 
problem. You either need to change the name or users will need to be 
explicit about which one they want.

(BTW - this is a question that could be asked on the R-devel list.)

Paul

On 13-12-31 06:00 AM, r-help-request at r-project.org wrote:
> Date: Mon, 30 Dec 2013 20:01:46 +0100
> From: Axel Urbiz<axel.urbiz at gmail.com>
> To: Duncan Murdoch<murdoch.duncan at gmail.com>
> Cc:"R-help at r-project.org"  <R-help at r-project.org>
> Subject: Re: [R] Package dependencies in building R packages
> Message-ID:
> 	<CAAyVsXKCN1Zn4gbG=QkD759kaDadPbgp+9e3W6nPvOLVwAsU=w at mail.gmail.com>
> Content-Type: text/plain
>
> 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.
>
> Best,
> Axel.
>
>
> On Mon, Dec 30, 2013 at 7:51 PM, Duncan Murdoch<murdoch.duncan at gmail.com>wrote:
>
>> >On 13-12-30 1:24 PM, Axel Urbiz wrote:
>> >
>>> >>Dear users,
>>> >>
>>> >>My package {foo} depends on a function "miscFUN" which is on package
>>> >>{foo_depend}. This last package also depends on other packages, say {A, B,
>>> >>C}, but miscFUN is not dependent on A, B, C (only on foo_depend).
>>> >>
>>> >>In my package {foo}, is there a way to only have it depend on the function
>>> >>miscFUN from {foo_depend} without having the user to have installed A, B,
>>> >>C? (as none of those packages are needed for my package to work properly).
>>> >>Also, is this a best practice?
>>> >>
>> >
>> >There's no way for your package to tell R to ignore the dependencies
>> >declared by foo_depend.
>> >
>> >If you really only need one function from that package, simply copy the
>> >source of miscFUN into your package (assuming foo_depend's license permits
>> >that).  But this is not best practice, unless that function is very simple.
>> >  Best practice is to declare your dependence by importing that function
>> >from foo_depend.
>> >
>> >Duncan Murdoch
>> >
>> >
>> >
> 	[[alternative HTML version deleted]]
>



More information about the R-help mailing list