[R-pkg-devel] package in 'Suggests'

Duncan Murdoch murdoch.duncan at gmail.com
Thu Oct 20 00:11:28 CEST 2016


On 19/10/2016 4:33 PM, Dirk Eddelbuettel wrote:
>
> On 19 October 2016 at 19:29, Berry Boessenkool wrote:
> | A package I am developing will have one additional (not core) function depending on RCurl.
> | To keep dependencies low, I am considering to put RCurl in 'Suggests' instead of 'Imports'.
> | Also, I guess some users / systems may not have libcurl installed.
> |
> | Then I would write something like
> | indexDWD <- function(...)
> | {
> | if(!requireNamespace("RCurl", quietly=TRUE))
> |   stop("The R package 'RCurl' is not available. indexDWD can not obtain file list.\n",
> |        "install.packages('RCurl')       to enable this.")
> | ... # otherwise do some nice stuff with RCurl::getURL
> | }
> |
> | Can /should I still have an example tested by CRAN? (I've seen \dontrun used in similar situations)
> | Or should CRAN check never depend on an ftp-server being accessible?
>
> What you have is the correct approach: test _if the package can be loaded_
> and if so, proceed.  Else skip the test.
>
> Some just put packages in Suggests: and then still assume them be installed.
> That's just wrong in my book, though not enforced as a fail by CRAN.

It's officially wrong, but not in our current suite of tests.

I think there would be some discussions on what is acceptable if the 
suggested package is missing:  I'd argue an error is the right thing if 
there isn't an alternate way to give the right answer, but that kind of 
error shouldn't cause your package to fail to be accepted.  However, we 
don't do those tests, because we currently don't have the resources to 
do so.

Duncan Murdoch



More information about the R-package-devel mailing list