[R-pkg-devel] Imports: vs Suggests:

Dirk Eddelbuettel edd at debian.org
Sat Jan 6 17:23:46 CET 2018


Hugh,

You may be looking at this from the wrong angle. "Imports" is really an
updated variant of "Depends".  Both of them declaure _unconditional_ use of
another package.  (How they are used is the fine distinction between loading
and attaching which we'll skip here). The key point is that a package named
by either of these _must_ be present.

"Suggests" is different as it declares _optional_ use for which you should
then test.  To take a simple example, Rcpp offers Rcpp.package.skeleton() by
extending / wrapping around package.skeleton().  If and when the _optional_
package pkgKitten (which is a Suggests: of Rcpp) is present, we use it:


    havePkgKitten <- requireNamespace("pkgKitten", quietly=TRUE)

    # ... stuff omitted

    ## update the package description help page
    if (havePkgKitten) {                # if pkgKitten is available, use it
        pkgKitten::playWithPerPackageHelpPage(name, path, maintainer, email)
    } else {
        ### other fallback code ....
    }

See https://github.com/RcppCore/Rcpp/blob/master/R/Rcpp.package.skeleton.R

Hth,  Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list