11.5 Package is listed in Depends

Recall from Chapter 10:

Prior to the roll-out of namespaces in R 2.14.0 in 2011, Depends was the only way to “depend” on another package… The most legitimate current use of Depends is to state a minimum version for R itself, e.g. Depends: R (>= 4.0.0).

Depends shouldn’t be used for packages.. but if you do use it will be similar to Imports e.g. your package can assume that aaapkg will be installed but unlike Imports, aaapkg will be attached as well.

11.5.1 In code below R/ and in test code

Same as using functions from a package listed in Imports

  • use aaapkg::aaa_fun()

  • Import an individual function using an @importFrom roxygen tag

  • Import the entire namespace using @import roxygen tag

11.5.2 In examples and vignettes

Because your package is attached when the examples are executed you wont need to use library().

Similarly, if your vignette starts with library(pkg), your package will be loaded and attached along with any packages listed in the Depends field.