The renv package[^1] helps you create reproducible environments for your R projects. Use renv to make your R projects more isolated, portable and reproducible.
Install the latest version of renv from CRAN with:
install.packages("renv")
Use renv::init()
to initialize renv in a new or existing project. This
will set up a project library, containing all the packages you’re
currently using. The packages (and all the metadata needed to reinstall
them) are recorded into a lockfile, renv.lock
, and a .Rprofile
ensures that the library is used every time you open that project.
As you continue to work on your project, you will install and upgrade
packages, either using install.packages()
and update.packages
or
renv::install()
and renv::update()
. After you’ve confirmed your code
works as expected, use renv::snapshot()
to record the packages and
their sources in the lockfile.
Later, if you need to share your code with someone else or run your code
on new machine, your collaborator (or you) can call renv::restore()
to
reinstall the specific package versions recorded in the lockfile.
If this is your first time using renv, we strongly recommend starting with the Introduction to renv vignette: this will help you understand the most important verbs and nouns of renv.
If you have a question about renv, please first check the FAQ to see whether your question has already been addressed. If it hasn’t, please feel free to ask on the RStudio Community forums.
If you believe you’ve found a bug in renv, please file a bug (and, if possible, a reproducible example) at https://github.com/rstudio/renv/issues.
[^1]: Pronounced “R” “env”
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.