Learn R Programming

⚠️There's a newer version (1.1.7) of this package.Take me there.

renv

Overview

The renv package helps you create reproducible environments for your R projects. Use renv to make your R projects more:

Isolated: Installing a new or updated package for one project won't break your other projects, and vice versa. That's because renv gives each project its own private package library.

Portable: Easily transport your projects from one computer to another, even across different platforms. renv makes it easy to install the packages your project depends on.

Reproducible: renv records the exact package versions you depend on, and ensures those exact versions are the ones that get installed wherever you go.

Installation

Install the latest version of renv from CRAN with:

install.packages("renv")

You can also install the development version of renv from R-universe with:

install.packages("renv", repos = "https://rstudio.r-universe.dev")

Workflow

Use renv::init() to initialize renv with a new or existing project. This will set up your project with a private library, and also make sure to install all of the packages you're using into that library. The packages used in your project will be recorded into a lockfile, called renv.lock.

As you work in your project, you may need to install or upgrade different packages. As these packages are installed, renv will automatically write renv.lock for you. The renv.lock lockfile records the state of your project's private library, and can be used to restore the state of that library as required.

Later, if you need to port your project to a new machine, you can call renv::restore() to reinstall all of the packages as declared in the lockfile.

Learning More

You can browse the package documentation online at https://rstudio.github.io/renv/.

If this is your first time using renv, we strongly recommend reading the Introduction to renv vignette.

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 either 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.

Copy Link

Version

Install

install.packages('renv')

Monthly Downloads

1,188,437

Version

0.17.3

License

MIT + file LICENSE

Maintainer

Kevin Ushey

Last Published

April 6th, 2023

Functions in renv (0.17.3)

equip

Install Required System Libraries
refresh

Refresh the Local Cache of Available Packages
purge

Purge Packages from the Cache
project

Retrieve the Active Project
scaffold

Generate renv Project Infrastructure
settings

Project Settings
modify

Modify a Lockfile
paths

Path Customization
renv-package

Project-local Environments for R
rehash

Re-Hash Packages in the renv Cache
status

Status
snapshot

Snapshot a Project
remote

Resolve a Remote
remove

Remove Packages
renv_lockfile_from_manifest

Generate renv.lock from an RStudio Connect manifest.json
revert

Revert Lockfile
lockfiles

Lockfiles
migrate

Migrate a Project from Packrat to renv
run

Run a Script
use

Use a set of Packages
use_python

Use Python
vendor

Vendor renv in an R Package
rebuild

Rebuild the Packages in your Project Library
graph

Generate a Package Dependency Graph
restore

Restore a Project
update

Update Packages
record

Update Package Records in a Lockfile
repair

Repair a Project Library
upgrade

Upgrade renv
config

User-Level Configuration of renv
deactivate

Deactivate a Project
consent

Consent to usage of renv
activate

Activate a Project
clean

Clean a Project
dependencies

Find R Package Dependencies in a Project
lockfile

Programmatically Create and Modify a Lockfile
hydrate

Hydrate a Project
embed

Embed a Lockfile
autoload

Auto-load the Active Project
imbue

Imbue an renv Installation
diagnostics

Print a Diagnostics Report
history

View Lockfile History
isolate

Isolate a Project
load

Load a Project
install

Install Packages
checkout

Checkout a Repository
init

Initialize a Project