using renv to manage R packages in a project

Introduction

renv is a package that helps you manage R packages in a project. renv enables you to create a project-specific library of R packages. It is very flexible, allowing you to use any R package repository, including CRAN, Bioconductor, and GitHub.

Installation

renv is available on CRAN, so you can install it with install.packages():

install.packages("renv")

Restore a previously saved project

renv::restore()

Initializing a project

renv::init()

When packages have been changed

renv::snapshot()

Change renv .cache location

Check here for more information: https://rstudio.github.io/renv/reference/paths.html

Sys.setenv(RENV_PATHS_ROOT = "<new_directory>/_cache_R")