Skip to content
Prev 2438 / 12125 Next

[R-pkg-devel] How to (conditionally) use an archived package (without Suggests)?

On Sun, Feb 25, 2018 at 1:41 AM, Duncan Murdoch
<murdoch.duncan at gmail.com> wrote:
Hi,

the 'workaround' is the error: to tell the user not to use it (but one
of the other available methods).

To be more precise: 'bar' is the package 'loon' for dynamic graphics
(and 'foo' is 'zenplots'). If that's not installed, the user can
choose to work with the other (non-dynamic) graphics packages. If a
user actively chooses to do the plotting with loon but doesn't have
loon installed, the error is a logical consequence.
The main plotting function in zenplots uses:

    if(pkg == "loon" && !requireNamespace("loon", quietly = TRUE))
        stop("Package 'loon' is not available.")

... and if it's installed, it will call various further functions from
loon (now all used via "loon::..."). There are no tests or examples
that fail, everything works -- it's just that the use of "::"
generates the warning I mentioned which is (most likely) unacceptable
for upload to CRAN.
It does -- except for the 'warning':

'::' or ':::' import not declared from: ?bar?
'loadNamespace' or 'requireNamespace' call not declared from: ?bar?
'loon' is not in Suggests. It originally was in 'Imports', then I put
it to 'Suggests', but when I submitted, Uwe wrote:
But you still have
Suggests: loon,
Please fix and resubmit.

... so it shouldn't appear in 'Suggests' either (I guess). That's why
I also removed it from Suggests, but then (because of the above
warning), I can't submit either.

Not sure how to solve this (... and thought that others might have a
similar problem with archived packages -- thus this post).

Cheers,
Marius