[R] Issue with Imports in NAMESPACE

Martin Morgan mtmorgan at fhcrc.org
Tue Jun 25 15:53:20 CEST 2013


On 06/25/2013 01:19 PM, Duncan Murdoch wrote:
> On 13-06-25 7:14 AM, Søren Højsgaard wrote:
>> Dear Duncan,
>>
>> Excellent, thanks!
>>
>> Maybe this is worth a remark in a future version of "Writing R Extensions"
>> (including that those "local copies" are not exported again with
>> exportPattern("^[[:alpha:]]+")).
>
> It is mentioned that they can be exported.  The fact that exportPattern doesn't
> see them might be a bug.

In some ways I would have expected R CMD check to complain that maxClique was 
not documented, because after all the user can have access to maxClique (after 
library(gRbase)) but not have access to it's documentation

 > library(PkgA) ## Imports: RBGL; importFrom(RBGL, maxClique); export(maxClique)
 > ?maxClique
No documentation for 'maxClique' in specified packages and libraries:
you could try '??maxClique'
 > R.version.string
[1] "R Under development (unstable) (2013-06-25 r63053)"

Personally, if the intention is to make functionality of RBGL available to the 
end user (even a small part) then I would have Depends: RBGL. Regardless of 
whether RBGL appears in the Depends: or Imports: field of the DESCRIPTION, I
would have import'ed maxClique into the gRbase name space (so that function 
resolution occurs correctly within the package, even when gRbase is import'ed 
into another package). Having two apparent ways of arriving at the same function 
(gRbase::maxClique, RBGL::maxClique) seems to be inviting confusion.

Martin

>
> Duncan
>
>>
>> Thanks!
>>
>> Søren
>>
>> -----Original Message-----
>> From: Duncan Murdoch [mailto:murdoch.duncan at gmail.com]
>> Sent: 25. juni 2013 13:02
>> To: Søren Højsgaard
>> Cc: R hELP (r-help at stat.math.ethz.ch)
>> Subject: Re: [R] Issue with Imports in NAMESPACE
>>
>> On 13-06-25 6:50 AM, Søren Højsgaard wrote:
>>> Dear all,
>>> In my gRbase package I have up until now "Depend"-ed on RBGL (from
>>> Bioconductor), but good people have convinced me that I should use
>>> "Import"-it instead because I only use few functions from RBGL.
>>>
>>> In DESCRIPTION I therefore now have
>>> Imports: Matrix,RBGL
>>>
>>> In NAMESPACE I now have
>>> importFrom(RBGL, maxClique, is.triangulated, separates)
>>>
>>> The package compiles without complaints, but I have noticed that if I start a
>>> fresh R-session, then maxClique etc. from RBGL is NOT available for
>>> "interactive use" in my session:
>>>> library(gRbase)
>>>> maxClique
>>> Error: object 'maxClique' not found
>>>
>>> 1) Is this as it should be?
>>>
>>> 2) If yes, is there any other way in which maxClique can be imported for
>>> interactive use without Depend-ing the whole RBGL package?
>>
>> The importFrom directive effectively makes local copies of those functions in
>> your package (with the usual caveats that copies aren't as inefficient as you
>> might think).  If you want to export them, you need to add them to the exports
>> list.
>>
>> Duncan Murdoch
>>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.


-- 
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109

Location: Arnold Building M1 B861
Phone: (206) 667-2793



More information about the R-help mailing list