Given a set of R package requirements, install those packages into the
library path requested via library
, and then activate that library path.
Usage
use(
...,
lockfile = NULL,
library = NULL,
isolate = FALSE,
sandbox = TRUE,
attach = FALSE,
verbose = TRUE
)
Arguments
- ...
The R packages to be used with this script. Ignored if
lockfile
is non-NULL
.- lockfile
The lockfile to use. When supplied,
renv
will use the packages as declared in the lockfile.- library
The library path into which the requested packages should be installed. When
NULL
(the default), a library path within the R temporary directory will be generated and used. Note that this same library path will be re-used on future calls torenv::use()
, allowingrenv::use()
to be used multiple times within a single script.- isolate
Boolean; should the active library paths be included in the set of library paths activated for this script? Set this to
TRUE
if you only want the packages provided torenv::use()
to be visible on the library paths.- sandbox
Should the system library be sandboxed? See the sandbox documentation in config for more details. You can also provide an explicit sandbox path if you want to configure where
renv::use()
generates its sandbox. By default, the sandbox is generated within the R temporary directory.- attach
Boolean; should the set of requested packages be automatically attached? If
TRUE
, packages will be loaded and attached via a call tolibrary()
after install. Ignored iflockfile
is non-NULL
.- verbose
Boolean; be verbose while installing packages?
Details
renv::use()
is intended to be used within standalone R scripts. It can
be useful when you'd like to specify an R script's dependencies directly
within that script, and have those packages automatically installed and
loaded when the associated script is run. In this way, an R script can more
easily be shared and re-run with the exact package versions requested via
use()
.
renv::use()
is inspired in part by the groundhog
package, which also allows one to specify a script's R package requirements
within that same R script.