Although package management in R is robust thanks to CRAN1 The Comprehensive R Archive Network and R’s built-in facilities for installing and managing packages2 R Installation and Administration: Add-on packages, it still may arise that different projects on your systems may require different package versions.
The renv
3 renv: Project environments for R project aims to make isolating and specifying R project package dependencies easy.
install.packages("renv")
renv::init()
This creates the lock file and renv/
data directory4 renv: Infrastructure.
Installing/removing from CRAN from within the project directory works normally.
Renv also includes a more comprehensive install
5 Install Packages function.
renv::install("<package>")
It can install directly from Github:
renv::install("<user>/<repo>")
View repo-lockfile synchronization status6 Status:
renv::status()
Save the currently-installed package versions to the lock file7 Snapshot a Project:
renv::snapshot()
Restore snapshots8 Restore a Project, which (re)installs the versions of all packages recorded in the lock file:
renv::restore()