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. Dirk -- http://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org ______________________________________________ R-package-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel