[Rd] Depends/Imports/Suggest/Enhence

Simon Urbanek simon.urbanek at r-project.org
Tue Nov 6 21:17:41 CET 2012

On Nov 6, 2012, at 2:44 PM, Davor Cubranic wrote:

> On 2012-11-06, at 9:49 AM, Uwe Ligges wrote:
>> On 06.11.2012 17:55, Christophe Genolini wrote:
>>>> "Imports" means that symbols are imported form the namespace, so they
>>>> are mandatory for the package to operate. "Suggests" means that
>>>> symbols from the package are not required, but they are used in
>>>> examples or vignettes, so the listed package(s) will be needed for a
>>>> full check. They are not needed for the operation of the package, though.
>>> That's very clear, thanks a lot.
>>> So I will use
>>> - 'Depends:foo1' if there is a function in foo1 that my package use often
>> No, better make use of Namespace imports all the time and only use "Depends" if you really need the other package to be installed. This is rarely needed.
> Uwe, did you mean to say "only use 'Depends' if the other package really needs to be *attached*"?

I think so.

BTW: this Depends/Imports is an interesting aspect that it may look trivial for package developers, but can be quite confusing for users. Uwe was suggesting Imports over Depends which is clean from a technical point of view (no namespace collisions etc.), but as an R user I have to say I find it bad since I used to be able to just load one package and not have to load (=attach) every package in the dependency tree that I may want to use myself by hand, but if people really decide to go that route, you'll have to do it for every single package which is a real pain. (Also it's a very bad thing for debugging - you can't even ask users to test things since the imports will be hidden). In addition, it hides declared methods which is, again, a pain when using R interactively, since you can't simply check what a certain method definition looks like - you'd have to hunt for it through namespaces (this is also related to not exporting methods). There is a difference in treating R as a scripting language versus an interactive analytics system and I find that recently focus has been shifting to the former aspect, while, personally, I think it's actually more useful as the latter. (Just my $0.02 off topic ;))


> Because in terms of determining dependencies for `install.package`, I thought "Imports" and "Depends" are no different. (Unless the user explicitly chooses otherwise in the 'dependencies' argument, that is.)
>>> - 'Imports:foo2' if there is a function in foo2 that my package might
>>> use rarely
> I don't think choosing to declare "Imports" has anything to do with frequency of use. But if you do use it, then don't forget to include "imports(foo2)" or "importsFrom(foo2, ...)" in the NAMESPACE file.
> Davor

More information about the R-devel mailing list