Given a set of R package requirements, install those packages into the
library path requested via library
, and then activate that library path.
use(
...,
lockfile = NULL,
library = NULL,
isolate = FALSE,
attach = FALSE,
verbose = TRUE
)
The R packages to be used with this script. Ignored if lockfile
is
non-NULL
.
The lockfile to use. When supplied, renv
will use the packages as
declared in the lockfile.
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 to renv::use()
, allowing renv::use()
to be used multiple times within a single script.
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 to renv::use()
to be visible on the library paths.
Boolean; should the set of requested packages be automatically attached?
If TRUE
, packages will be loaded and attached via a call
to library()
after install. Ignored if lockfile
is non-NULL
.
Boolean; be verbose while installing packages?
This function is normally called for its side effects.
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 provides an alternate mechanism for specifying a script's
R package requirements within that same R script.