{renv}
?{renv}
is an R package for managing project dependencies and creating reproducible environments
{renv}
{renv}
{renv}
Your project .Rprofile
is updated to include:
This is run every time R starts, and does some management of the library paths to make sure when you call install.packges("package")
or library(package)
it does to the right place (renv/library/R-{version}/{computer-specifics}
)
renv.lock
file (really just a text file) is created to store the names and versions of the packages.renv.lock
{
"R": {
"Version": "4.3.0",
"Repositories": [
{
"Name": "CRAN",
"URL": "https://cran.rstudio.com"
}
]
},
"Packages": {
"R6": {
"Package": "R6",
"Version": "2.5.1",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "470851b6d5d0ac559e9d01bb352b4021"
},
base64enc": {
"Package": "base64enc",
"Version": "0.1-3",
"Source": "Repository",
"Repository": "CRAN",
"Requirements": [
"R"
],
"Hash": "543776ae6848fde2f48ff3816d0628bc"
},
{renv}
laterRestore an environment
Install new packages
Update the lockfile
{renv}
renv.lock
file with collaborators to ensure consistent environmentsrenv::restore()
, the correct versions of the packages will be installed on their computerRemove packages that are no longer used:
Check the status of the project library with respect to the lockfile:
This will tell you to renv::snapshot()
to add packages you’ve installed but haven’t snapshotted, or renv::restore()
if you’re missing packages you need but which aren’t installed
{renv}
benefits:
Getting started with {renv}
renv::init()
renv::snapshot()
renv::restore()
Additional resources