Reputation: 109232
The DESCRIPTION
file in R packages has several ways of specifying dependencies, e.g. Depends
, Suggests
and Imports
. Which one should I use to specify a dependency that is optional once the package is installed, but required for running R CMD check
?
In my particular case I am using testthat
to run some tests automatically when R CMD check
is run, but during "normal" operation, testthat
is not required. The answer to this question suggests that testthat
should be in Suggests
, but is that enough to ensure that R CMD check
runs correctly?
What I would like to see, if it exists, is a field where I can speciy dependencies that are required only to run R CMD check
, which should fail with an appropriate error message if these packages are not available.
Upvotes: 1
Views: 2407
Reputation: 176648
Yes, you should put them in the Suggests
field. The only other thing required for R CMD check
to run successfully is to ensure the packages in the Suggests
field are installed in a location that will be found by R CMD check
.
If they're not available, you can set the environment variable _R_CHECK_FORCE_SUGGESTS=false
and R CMD check
will run, with a "NOTE" about the missing suggested packages.
Upvotes: 5