Use: or export all when developing multiple related R packages?

I am working on a family of R-packages, all of which have a common common code, which is located in an internal package, allows you to call it myPackageUtilities. Therefore, I have several packages

myPackage1, myPackage2etc.

All of these packages depend on each method in myPackageUtilities. For an example in the real world, see statnet on CRAN . Of course, every dependent package has

Depends: myPackageUtilities

in the DESCRIPTION file.

My question: In R code, it is myPackage1preferable to use one of the following two methods to access methods from myPackageUtilities:

  • Use :::to access methods in myPackageUtilitiesor
  • Export all from myPackageUtilities(e.g. include exportPattern("^[^\\.]")in NAMESPACE)

Option 2 clutters the end user search path, but R gurus are advised not to use it :::.

Follow-up question: If (2) is the best choice, is there a way to export everything with roxygen2?

+4
source share
1 answer

Suppose we have a package called randomUtils, and this package has a function called sdthat calculates Slytherin deficiency coefficient.

spellbound. spellbound randomUtils, randomUtils::sd .

spellbound randomUtils, R randomUtils, spellbound. , sd , randomUtils::sd

CRAN , , , .

, Depends: HydeNet , rjags HydeNet. rjags Depends , library (HydeNet) . ( , rjags .

, , , .

+3

Source: https://habr.com/ru/post/1626462/


All Articles