Virtual Environments in R
The most common way to use a virtual environment in R is through the renv
package, developed by Posit. The best place to learn about using renv
is the package's introductory vignette here, which provides a brief overview of the package and everything you need to get started.
You can also see examples of renv
being used in practice in many of our R codebases on the lab GitHub, including:
- The physician to voter codebase, which uses
renv
to ensure reporoducibility and make sure that it will still run even if a server user updates their package libraries. - The TMSIS ingestion pipeline, which uses
renv
to help ensure that all maintainers are using the same version of the dependency packages.