Skip to content
Prev 46683 / 63424 Next

declaring package dependencies

Michael

(Several of us are struggling with these changes, so my comments are 
from the newly initiated point of view, rather than the fully 
knowledgeable.)
On 13-09-12 09:38 AM, Michael Friendly wrote:
Lots in this respect.
The "modern" way of thinking about this is that the Depends line should 
not have much in it, only things from other packages that you want 
directly available to the user. (There are a few other exceptions 
necessary for packages that have not themselves embraced the "modern" 
way.) Since you may want users of vcdExtra to automatically have access 
to functions in vcd, without needing to execute library(vcd), this 
classifies as one of the official exceptions and you probably want cvd 
in the Depends line. However, chances are that gnm should be in 
Imports:. If vcd is in the Depends line then it is automatically 
attached and your examples do not need library(vcd) or requires(vcd).

The Note

   Unexported object imported by a ?:::? call: ?vcd:::rootogram.default?

is harder to decide how to deal with. (This is sill just a note, but it 
looks to me like a note that will soon become a warning or error.) The 
simple solution is to export rootogram.default from vcd, but that 
exposes it to all users, and really you may just want to expose it to 
packages like vcdExtra. There was some recent discussion about this on 
R-devel. I suggested one possibility would be some sort of limited 
export. Since that was a suggestion that required work by someone else, 
it probably went the same place as most of those suggestion do. The 
solution I have adopted for the main case where this causes me problems 
is to split the classes, generics, and methods into one package, and the 
user functions into another. For example, if you have rootogram.default 
in a package called vcdClasses and exported it, then both vcd and 
vcdExtra can import it, but if it is not in their Depends line then it 
will not be visible to a user that executes library(vcd) or 
library(vcdExtra).

Beware that there is currently a small gotcha if the generics are S3, 
which was discussed recently and a patch submitted by Henrik Bengtsson 
(See Re: [Rd] "False" warning on "replacing previous import" when 
re-exporting identical object .)


Although there has been much moaning about these changes, including my 
own, I think the general logic is a real improvement. The way I think of 
it, the namespace imports for a package provide the equivalent of a 
search path for functions in the package, which is not changed by what 
packages a user or other packages attach or import. Thus a package 
developer has much more certain control over where the functions used by 
the package will come from. This is a trade-off for safety rather than 
convenience, thus the moaning. I am a complete newbie on this, but there 
seems to be a pretty good unofficial description at 
http://obeautifulcode.com/R/How-R-Searches-And-Finds-Stuff/.
If it is only in Suggests you can refer to it in the example by 
MASS::loglm(), or require(MASS)/library(MASS). (I might have that wrong, 
at least one works but I'm not certain of both.)
Probably grid and stats should be in Imports.
Are you actually getting anything to build on R-forge? All my packages 
have been stuck for a couple of weeks, as have many others.

Paul

Thread (28 messages)

Michael Friendly declaring package dependencies Sep 12 Paul Gilbert declaring package dependencies Sep 12 Duncan Murdoch declaring package dependencies Sep 12 Michael Friendly declaring package dependencies Sep 13 Duncan Murdoch declaring package dependencies Sep 13 Dirk Eddelbuettel Fortune! (Re: declaring package dependencies) Sep 13 Dirk Eddelbuettel declaring package dependencies Sep 13 Brian Ripley declaring package dependencies Sep 13 Duncan Murdoch declaring package dependencies Sep 13 Duncan Murdoch declaring package dependencies Sep 13 Dirk Eddelbuettel declaring package dependencies Sep 13 Paul Gilbert declaring package dependencies Sep 13 Dirk Eddelbuettel declaring package dependencies Sep 13 John Fox declaring package dependencies Sep 13 Gray Calhoun declaring package dependencies Sep 13 Achim Zeileis Fortune! (Re: declaring package dependencies) Sep 14 Duncan Murdoch declaring package dependencies Sep 14 Dirk Eddelbuettel declaring package dependencies Sep 14 Brian G. Peterson declaring package dependencies Sep 14 Paul Gilbert declaring package dependencies Sep 14 Duncan Murdoch declaring package dependencies Sep 14 Duncan Murdoch declaring package dependencies Sep 14 Duncan Murdoch declaring package dependencies Sep 14 Dirk Eddelbuettel declaring package dependencies Sep 14 Michael Friendly declaring package dependencies Sep 15 Duncan Murdoch declaring package dependencies Sep 15 Paul Gilbert declaring package dependencies Sep 15 Brian Lee Yung Rowe declaring package dependencies Sep 15