jmxsy2016 / renv-rspm

Testing renv and RStudio Package Manager

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Testing renv and RStudio Package Manager

This repo provides a quick example of how to combine renv and RStudio Package Manager (RSPM) to create a reproducible R project.

The repo contains a single demo script, creatively called script.R. To install all of the R packages needed to run this script, simply clone the repo and then run the following commands in your R console:

#renv::init()    ## Automatically run if you cloned/opened the repo as an RStudio project
renv::restore()  ## Enter "y" when prompted

This will automatically download all of the necessary packages in a sandboxed, project-specific library. You are now free to run my (amazing) script.

Details

renv generates an environment lockfile that snapshots package versions and dependencies. The lockfile here references against RSPM as the default package repository (i.e. where to download packages from), rather than one of the usual CRAN mirrors. Among other things, this enables time-travelling across different package versions and fast installation of pre-compiled R package binaries on Linux.

While renv and RSPM certainly can work independently of another, they work very well as complements. One reason is that you need simply set the base RSPM repo URL (e.g. options(repos = c(RSPM = "https://packagemanager.rstudio.com/all/latest"))) and renv will automatically transform the URL so that it fetches the binaries appropriate for your platform (OS, distro, etc.), or whoever else you have shared your lockfile with.

About

Testing renv and RStudio Package Manager


Languages

Language:R 100.0%