Handing an R Project to a Collaborator with renv
Two analyses share a laboratory computer. Updating a package for a new paper may change the functions used by last year's report. Copying every installed package to a colleague also carries across machine-specific paths and unrelated dependencies. With renv, each R project has a library of installed packages and a reviewable record of the versions it needs. Collaborators share that record and build their own installations.[1][2]
Give the project its own library
Open the paper's project directory and run renv::init(). In an existing project, renv discovers dependencies, creates a project library and initial lockfile, and configures the project to activate renv when R starts there. A library holds installed packages. A repository supplies packages. A lockfile describes the state a collaborator should reconstruct. Receiving the third does not immediately populate the first.[1]
Suppose the new paper needs an updated data-management package. Open that project and use renv::install() to install the package there. Run the affected analysis and inspect its outputs. Your installed environment has changed, but the lockfile may still describe the previous state. At the time of checking, CRAN listed version 1.3.1 of renv under MIT plus the accompanying license file. The relevant versions for a particular paper remain those in its lockfile.[1][3]
Read the direction of the operation
Once satisfied with the change, run renv::snapshot() and review the proposed differences. The lockfile records package names, versions and sources. Commit the updated record alongside the code that requires it. A reviewer can then see why a dependency changed. Sharing the script alone may leave collaborators with the old package. Sharing an untested lockfile does not establish that the paper's table can still be generated.[1][2]
Figure: Snapshot and restore across two project libraries.
If the experiment fails and the lockfile still describes the working state, renv::restore() takes the opposite direction. Review its proposed changes and restore the project library from the record. Decide which side represents the state worth keeping before responding to a mismatch. For an earlier submission, recover the lockfile committed with that version of the scripts rather than guessing which transitive dependency was in use.[1][2]
Make the handover in a fresh session
Commit the scripts, renv.lock, .Rprofile, renv/activate.R and renv/settings.json. A collaborator starts a fresh R session in the project, lets the loader configure the library path, then restores missing packages. The installed library does not belong in the shared repository. A small input that exercises the script for the main table gives the collaborator a quick check of the output columns and row count before running the full analysis.[1][2]
The lockfile records the R version but does not install the interpreter. Pandoc and system development libraries have their own installation paths. Record the interpreter, operating system and rendering tool versions when you need to compare a new machine with the original one. An analysis that runs and then fails when rendering the report may be missing a different component entirely. To stop using renv in this project, ordinary renv::deactivate() removes the automatic loader while retaining other project files for later use. The practical handover test is whether the collaborator can regenerate the table.[1]
References
Originally published at EnterScholar.

Top comments (1)
The "direction of the operation" framing is the clearest explanation of renv I've seen โ snapshot moves the state from your library into the lockfile, restore moves it back, and the lockfile sits between two independent libraries. That one diagram probably does more for a new collaborator than a page of commands. The lab-computer scenario is also the perfect motivation: two analyses sharing one machine, where updating a package for a new paper silently changes last year's report, is exactly how reproducibility quietly dies. And I appreciate the honest caveat that the lockfile records the R version but doesn't install the interpreter, and that Pandoc and system development files live outside renv entirely โ that's the gap that actually bites people on handover day. When a collaborator's restore fails on a system dependency like that, do you document those requirements in the repo, or do you wrap the project in a container so the handover is genuinely one command?