Create a renv lock file

createRenvLockFile(
  rootPackage,
  mode = "auto",
  includeRootPackage = TRUE,
  additionalRequiredPackages = NULL,
  ohdsiGitHubPackages = getOhdsiGitHubPackages(),
  ohdsiStudiesGitHubPackages = rootPackage,
  fileName = "renv.lock",
  restart = (mode == "auto")
)

Arguments

rootPackage

The name of the root package, the package that we'd like to be able to run in the end.

mode

Can be "auto" or "description". See details.

includeRootPackage

Include the root package in the renv file?

additionalRequiredPackages

Additional packages we want to have installed (with their dependencies), such as 'keyring'. Ignored if mode = "auto".

ohdsiGitHubPackages

Names of R packages that need to be installed from the OHDSI GitHub.

ohdsiStudiesGitHubPackages

Names of R packages that need to be installed from the OHDSI-Studies GitHub.

fileName

Name of the lock file to be generated. Ignored if mode = "auto".

restart

Boolean; attempt to restart the R session after initializing the project?

Value

Does not return a value. Is executed for the side-effect of creating the lock file.

Details

Create a lock file that allows reconstruction of the R environment using the renv package. This function will include the root file and all of its dependencies in the lock file, requiring the same package versions as currently installed on this computer.

If mode = "auto", this function will invoke renv::init(), which in turn will scan the project folders for any dependencies that are referenced. Afterwards, references to OHDSI packages will be altered so the correct GitHub tags are used for the installed versions.

If mode = "description", this function will assume the project is a full-fledged R package with up-to-date DESCRIPTION, and will only install the dependencies listed in the DESCRIPION.

The second option tends to lead to smaller lock files, but requires all dependencies are accurately listed in the DESCRIPTION file of the study package.