This can be placed as the first line of any/all scripts and it will be create a reproducible, self-contained project with R packages. Some of these have direct relationships with RequireOptions and arguments in setLibPaths and Require.

setup(
  RPackageFolders = getOption("RPackageFolders", "R"),
  RPackageCache = getOption("RPackageCache", "~/.cache/R/RequirePkgCache"),
  buildBinaries = getOption("buildBinaries", TRUE),
  standAlone = getOption("standAlone", TRUE)
)

setupOff(removePackages = FALSE)

Arguments

RPackageFolders

One or more folders where R packages are installed to and loaded from. In the case of more than one folder provided, installation will only happen in the first one.

RPackageCache

See ?RequireOptions.

buildBinaries

See ?RequireOptions.

standAlone

Logical. If TRUE, all packages will be installed to and loaded from the libPaths only. If FALSE, then libPath will be prepended to .libPaths() during the Require call, resulting in shared packages, i.e., it will include the user's default package folder(s). This can be create dramatically faster installs if the user has a substantial number of the packages already in their personal library. Default FALSE to minimize package installing.

removePackages

Logical. If TRUE, then all packages that were installed in the custom library will be deleted when setupOff is run. The default is FALSE, and when TRUE is selected, and it is an interactive session, the user will be prompted to confirm deletions.

Examples

# Place this as the first line of a project if (FALSE) { Require::setup() # To turn it off and return to normal Require::setupOff() }