{"id":13709,"date":"2026-04-14T16:48:15","date_gmt":"2026-04-14T20:48:15","guid":{"rendered":"https:\/\/labs.icahn.mssm.edu\/minervalab\/?page_id=13709"},"modified":"2026-04-14T17:04:32","modified_gmt":"2026-04-14T21:04:32","slug":"renv","status":"publish","type":"page","link":"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/renv\/","title":{"rendered":"Renv"},"content":{"rendered":"<p>[et_pb_section fb_built=&#8221;1&#8243; fullwidth=&#8221;on&#8221; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_fullwidth_menu menu_id=&#8221;15&#8243; menu_style=&#8221;centered&#8221; fullwidth_menu=&#8221;on&#8221; active_link_color=&#8221;#d80b8c&#8221; dropdown_menu_line_color=&#8221;#221f72&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; menu_font=&#8221;|600|||||||&#8221; menu_text_color=&#8221;#FFFFFF&#8221; menu_font_size=&#8221;16px&#8221; background_color=&#8221;#221f72&#8243; background_layout=&#8221;dark&#8221; sticky_position=&#8221;top&#8221; global_colors_info=&#8221;{}&#8221;][\/et_pb_fullwidth_menu][\/et_pb_section][et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;0px||0px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.16&#8243; background_size=&#8221;initial&#8221; background_position=&#8221;top_left&#8221; background_repeat=&#8221;repeat&#8221; custom_padding=&#8221;||0px||false|false&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; custom_padding=&#8221;|||&#8221; global_colors_info=&#8221;{}&#8221; custom_padding__hover=&#8221;|||&#8221;][et_pb_text admin_label=&#8221;Breadcrumb&#8221; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<p><a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/scientific-computing-and-data\/\">Scientific Computing and Data<\/a> \/ <a href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/\">High Performance Computing<\/a> \/ <a title=\"Documentation\" href=\"https:\/\/labs.icahn.mssm.edu\/minervalab\/documentation\/\">Documentation<\/a> \/ renv<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section][et_pb_section fb_built=&#8221;1&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_row _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; module_alignment=&#8221;center&#8221; custom_margin=&#8221;|auto||90px||&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_column type=&#8221;4_4&#8243; _builder_version=&#8221;4.16&#8243; _module_preset=&#8221;default&#8221; global_colors_info=&#8221;{}&#8221;][et_pb_text admin_label=&#8221;conda introduction&#8221; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; global_colors_info=&#8221;{}&#8221;]<\/p>\n<h1>Reproducible R Environments with renv<\/h1>\n<h3><b><span style=\"color: #221f72\">Contents<\/span><\/b><br \/>\n<a href=\"#overview\"><span style=\"color: #00aeef\">Overview of renv<\/span><\/a><br \/>\n<a href=\"#usage\"><span style=\"color: #00aeef\">Usage<\/span><\/a><\/h3>\n<p>&nbsp;<\/p>\n<h2 id=\"overview\">Overview of renv<\/h2>\n<p><strong>renv<\/strong> is an R package designed to help you manage project-specific libraries in a reproducible and isolated way. It creates a dedicated environment for each project, ensuring that the exact package versions used are recorded and can be restored later. This makes it easier to share code, collaborate with others, and reproduce results across different systems. By using <code>renv<\/code>, you avoid conflicts between projects and maintain consistency in your R workflows.<\/p>\n<p><strong>Key Features of <code>renv<\/code><\/strong><\/p>\n<ul>\n<li><strong>Project Isolation<\/strong> \u2013 Creates a separate library for each project, preventing package conflicts across projects.<\/li>\n<li><strong>Reproducibility<\/strong> \u2013 Captures exact package versions in a lockfile (<code>renv.lock<\/code>) so environments can be restored reliably.<\/li>\n<li><strong>Easy Environment Restore<\/strong> \u2013 Reinstalls all dependencies with a single command (<code>renv::restore()<\/code>), ensuring consistency across systems.<\/li>\n<li><strong>Lightweight Dependency Management<\/strong> \u2013 Only installs packages actually used in the project, reducing unnecessary overhead.<\/li>\n<li><strong>Integration with Version Control<\/strong> \u2013 Works seamlessly with Git by tracking the lockfile while ignoring local libraries.<\/li>\n<li><strong>Automatic Dependency Detection<\/strong> \u2013 Scans project files to identify required packages.<\/li>\n<li><strong>Caching for Efficiency<\/strong> \u2013 Uses a global cache to speed up installations and reduce disk usage.<\/li>\n<li><strong>Cross-Platform Consistency<\/strong> \u2013 Helps reproduce environments across different machines (local, HPC, cloud).<\/li>\n<li><strong>Minimal Workflow Changes<\/strong> \u2013 Fits naturally into existing R workflows with simple commands like <code>init()<\/code>, <code>snapshot()<\/code>, and <code>restore()<\/code>.<\/li>\n<\/ul>\n<p>[\/et_pb_text][et_pb_text admin_label=&#8221;conda usage&#8221; _builder_version=&#8221;4.27.4&#8243; _module_preset=&#8221;default&#8221; header_font=&#8221;|600|||||||&#8221; header_text_color=&#8221;#221f72&#8243; header_font_size=&#8221;26px&#8221; header_2_text_color=&#8221;#221f72&#8243; header_2_font_size=&#8221;24px&#8221; module_alignment=&#8221;center&#8221; custom_margin=&#8221;50px||||false|false&#8221; hover_enabled=&#8221;0&#8243; global_colors_info=&#8221;{}&#8221; sticky_enabled=&#8221;0&#8243;]<\/p>\n<h2 id=\"usage\">Usage<\/h2>\n<h3>1. Initializing a Project<\/h3>\n<p>To start using renv in a new or existing project, run:<\/p>\n<pre><code>renv::init()<\/code><\/pre>\n<h4>What this does:<\/h4>\n<ul>\n<li>Creates a <strong>project library<\/strong>: a private folder for project-specific packages<\/li>\n<li>Generates an <strong><code>renv.lock<\/code> file<\/strong>: records exact package versions for reproducibility<\/li>\n<li>Adds an <strong><code>.Rprofile<\/code> file<\/strong>: automatically activates the environment when the project is opened<\/li>\n<\/ul>\n<h3>2. Activating an Existing Project Environment<\/h3>\n<p>If renv is already set up but not active in your session:<\/p>\n<pre><code>renv::activate()<\/code><\/pre>\n<h4>What this does:<\/h4>\n<ul>\n<li>Switches the session to use the <strong>project-specific library<\/strong><\/li>\n<li>Ensures all package operations happen inside the isolated environment<\/li>\n<li>Useful when switching projects or working on HPC systems where auto-activation may not occur<\/li>\n<\/ul>\n<h3>3. Installing Packages<\/h3>\n<p><strong data-start=\"0\" data-end=\"9\" data-is-only-node=\"\">Note:<\/strong> To enable internet access for package installation on a compute node, please run the following code in the R console.<\/p>\n<blockquote>\n<pre><code>Sys.setenv(http_proxy=\"http:\/\/proxy.chimera.hpc.mssm.edu:3128\")\nSys.setenv(https_proxy=\"http:\/\/proxy.chimera.hpc.mssm.edu:3128\")\nSys.setenv(all_proxy=\"http:\/\/proxy.chimera.hpc.mssm.edu:3128\")\nSys.setenv(no_proxy=\"localhost,*.hpc.mssm.edu,*.chimera.hpc.mssm.edu,172.28.0.0\/16\")<\/code>\u00a0<\/pre>\n<\/blockquote>\n<p>Within an renv project, to install the latest version of a package:<\/p>\n<pre><code>install.packages(\"pkg\")\nrenv::install(\"pkg\")<\/code><\/pre>\n<p><code><\/code><\/p>\n<h4>Package Specification Options<\/h4>\n<table>\n<thead>\n<tr>\n<th data-col-size=\"md\">Repository<\/th>\n<th data-col-size=\"lg\">Command<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td data-col-size=\"md\">Specific CRAN version<\/td>\n<td data-col-size=\"lg\"><code>renv::install(\"pkg@1.2.3\")<\/code><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Latest version (force update)<\/td>\n<td data-col-size=\"lg\"><code>renv::install(\"pkg\")<\/code> or <code>renv::update(\"pkg\")<\/code><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">GitHub specific commit \/ tag<\/td>\n<td data-col-size=\"lg\"><code>renv::install(\"username\/repo@commit_hash\")<\/code> or <code>username\/repo@v1.2.3<\/code><\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Bioconductor specific version<\/td>\n<td data-col-size=\"lg\"><code>renv::install(\"bioc::DESeq2\")<\/code> (or with version via BiocManager <code>renv::settings$bioconductor.version(\"version\")<\/code>)<\/td>\n<\/tr>\n<tr>\n<td data-col-size=\"md\">Force reinstall \/ rebuild<\/td>\n<td data-col-size=\"lg\"><code>renv::install(\"pkg@1.2.3\", rebuild = TRUE)<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3><\/h3>\n<h4>What this does:<\/h4>\n<ul data-start=\"354\" data-end=\"656\" data-is-last-node=\"\" data-is-only-node=\"\">\n<li data-start=\"354\" data-end=\"446\">Provides different ways to specify where packages come from and which version to install<\/li>\n<li data-start=\"447\" data-end=\"558\">Supports installing specific CRAN versions, latest versions, GitHub commits\/tags, and Bioconductor packages<\/li>\n<li data-start=\"559\" data-end=\"656\" data-is-last-node=\"\">Enables precise control over package sources to ensure reproducible and consistent environments<\/li>\n<\/ul>\n<h3><\/h3>\n<h3>4. Snapshotting the Environment<\/h3>\n<p>After installing or updating packages, you record the environment state using:<\/p>\n<h4>Basic snapshot<\/h4>\n<pre><code>renv::snapshot()<\/code><\/pre>\n<h4>Full snapshot<\/h4>\n<pre><code>renv::snapshot(type = \"all\")<\/code><\/pre>\n<h4>Key difference:<\/h4>\n<table data-path-to-node=\"12\">\n<thead>\n<tr>\n<td><strong>Feature<\/strong><\/td>\n<td><strong>type = &#8220;implicit&#8221; (Default)<\/strong><\/td>\n<td><strong>type = &#8220;all&#8221;<\/strong><\/td>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><span data-path-to-node=\"12,1,0,0\"><b data-path-to-node=\"12,1,0,0\" data-index-in-node=\"0\">Primary Source<\/b><\/span><\/td>\n<td><span data-path-to-node=\"12,1,1,0\">Your code files (<code data-path-to-node=\"12,1,1,0\" data-index-in-node=\"17\">.R<\/code>, <code data-path-to-node=\"12,1,1,0\" data-index-in-node=\"21\">.Rmd<\/code>)<\/span><\/td>\n<td><span data-path-to-node=\"12,1,2,0\">Your library folder (<code data-path-to-node=\"12,1,2,0\" data-index-in-node=\"21\">renv\/library<\/code>)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span data-path-to-node=\"12,2,0,0\"><b data-path-to-node=\"12,2,0,0\" data-index-in-node=\"0\">Cleanliness<\/b><\/span><\/td>\n<td><span data-path-to-node=\"12,2,1,0\">High (only used packages)<\/span><\/td>\n<td><span data-path-to-node=\"12,2,2,0\">Low (contains everything installed)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span data-path-to-node=\"12,3,0,0\"><b data-path-to-node=\"12,3,0,0\" data-index-in-node=\"0\">Reliability<\/b><\/span><\/td>\n<td><span data-path-to-node=\"12,3,1,0\">Good (but can miss hidden dependencies)<\/span><\/td>\n<td><span data-path-to-node=\"12,3,2,0\">Perfect (captures everything present)<\/span><\/td>\n<\/tr>\n<tr>\n<td><span data-path-to-node=\"12,4,0,0\"><b data-path-to-node=\"12,4,0,0\" data-index-in-node=\"0\">Use Case<\/b><\/span><\/td>\n<td><span data-path-to-node=\"12,4,1,0\">Most standard data science projects.<\/span><\/td>\n<td><span data-path-to-node=\"12,4,2,0\">Complex production environments or &#8220;sealed&#8221; snapshots.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4><\/h4>\n<h4>What this does:<\/h4>\n<ul data-start=\"21\" data-end=\"404\" data-is-last-node=\"\" data-is-only-node=\"\">\n<li data-start=\"21\" data-end=\"111\">Saves the current R project\u2019s package environment into <code data-start=\"78\" data-end=\"89\">renv.lock<\/code> for reproducibility<\/li>\n<li data-start=\"112\" data-end=\"166\">Records exact package versions used in the project<\/li>\n<li data-start=\"167\" data-end=\"237\">Allows restoring the same environment later with <code data-start=\"218\" data-end=\"235\">renv::restore()<\/code><\/li>\n<\/ul>\n<h3>5. Reproducing Environments from renv.lock<\/h3>\n<p>To reproduce the environment elsewhere:<\/p>\n<pre><code>renv::restore()<\/code><\/pre>\n<h4>What this does:<\/h4>\n<ul>\n<li>Reads <code>renv.lock<\/code><\/li>\n<li>Installs exact package versions<\/li>\n<li>Recreates the project library<\/li>\n<\/ul>\n<h3>6. Package Management Tools<\/h3>\n<table>\n<thead>\n<tr>\n<th>Command<\/th>\n<th>Purpose<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>renv::status()<\/code><\/td>\n<td>Check consistency between library and lockfile<\/td>\n<\/tr>\n<tr>\n<td><code>renv::update()<\/code><\/td>\n<td>Update installed packages<\/td>\n<\/tr>\n<tr>\n<td><code>renv::clean()<\/code><\/td>\n<td>Remove unused packages<\/td>\n<\/tr>\n<tr>\n<td><code>renv::paths$library()<\/code><\/td>\n<td>Show project library location<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>7. Reproducibility Scope<\/h3>\n<p>renv ensures reproducibility of <strong>R package environments<\/strong>, but does not manage:<\/p>\n<ul>\n<li>R version itself<\/li>\n<li>System-level libraries (OS dependencies)<\/li>\n<li>External tools (e.g., Pandoc, compilers)<\/li>\n<\/ul>\n<h3>8. Summary<\/h3>\n<p>renv enables reproducible R environments by locking and restoring package versions across systems.<\/p>\n<p>The key idea:<\/p>\n<blockquote>\n<p>Use <code>snapshot()<\/code> for clean dependency tracking, and <code>snapshot(type = \"all\")<\/code> when you need a complete environment freeze.<\/p>\n<\/blockquote>\n<h3>9. Additional Resources<\/h3>\n<ul>\n<li><strong>renv Documentation (Posit)<\/strong><br \/><a href=\"https:\/\/rstudio.github.io\/renv\/\">https:\/\/rstudio.github.io\/renv\/<\/a><br \/>Official guide covering installation, workflows, snapshot\/restore, and reproducible R environments.<\/li>\n<li><strong>renv GitHub Repository<\/strong><br \/><a href=\"https:\/\/github.com\/rstudio\/renv\">https:\/\/github.com\/rstudio\/renv<\/a><br \/>Source code, release notes, issue tracking, and advanced usage discussions.<\/li>\n<li><strong>CRAN renv Package Page<\/strong><br \/><a href=\"https:\/\/cran.r-project.org\/package=renv\">https:\/\/cran.r-project.org\/package=renv<\/a><br \/>Official package page with version history, reference manual, and downloads.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>[\/et_pb_text][\/et_pb_column][\/et_pb_row][\/et_pb_section]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scientific Computing and Data \/ High Performance Computing \/ Documentation \/ renvReproducible R Environments with renv Contents Overview of renv Usage &nbsp; Overview of renv renv is an R package designed to help you manage project-specific libraries in a reproducible and isolated way. It creates a dedicated environment for each project, ensuring that the exact [&hellip;]<\/p>\n","protected":false},"author":624,"featured_media":0,"parent":35,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_et_pb_use_builder":"on","_et_pb_old_content":"","_et_gb_content_width":"","footnotes":""},"class_list":["post-13709","page","type-page","status-publish","hentry"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/13709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/users\/624"}],"replies":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/comments?post=13709"}],"version-history":[{"count":11,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/13709\/revisions"}],"predecessor-version":[{"id":13737,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/13709\/revisions\/13737"}],"up":[{"embeddable":true,"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/pages\/35"}],"wp:attachment":[{"href":"https:\/\/labs.icahn.mssm.edu\/minervalab\/wp-json\/wp\/v2\/media?parent=13709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}