R - equivalent of pip freeze (how to install all R dependencies from a file listing packages names and versions) -


i'm on new project there r code tons , tons of dependencies, , specific version of r (3.1.1). when wrote code used r's install.package('the-package') download recent version, many of dependencies have new versions make them incompatible r version used (the newest versions of packages instance dplyr, rcpp require r upgrade not possibility)

from experience r seems has worst package manager - i'm coming npm specify each package , specific version of package needed. huge pain (going on 5+ hours) resolve these dependencies manually, because apparently default behavior download bleeding edge of package. have been relatively successful far, clicking 'old sources' link on cran page package, downloading tars , installing their.. seems lot of unnecessary pain. i've had team member follow this guide list of dependencies , versions need (this @ least gives me possibility install packages front, , proceed trial , error, rather resolving 50+ dependencies individually each time build fails in new environment).. there no "r, process dependencies file" command.

  • javascript - use npm install package.json.
  • python - can pip freeze , pip install pip_freeze.txt, same concept
  • r - far can tell, no easy way download need if have specific needs do

this shell script modified download specific version of package

#!/bin/bash # cran doesn't have version of installable in our old r. wget -p /tmp https://cran.r-project.org/src/contrib/archive/rcpp/rcpp_0.12.5.tar.gz || { echo 'wget failed'; exit 1; } rscript -e "install.packages('/tmp/rcpp_0.12.5.tar.gz', repos = null, type='source')" 2>&1 | tee -a rpkginstall.log  if egrep "non-zero exit status|error in install.packages|^package .* not available" rpkginstall.log;     echo 'failed';     exit 1; fi 

how can make easier process next person joins team? documentation can go long way, i'm looking functional package manager in r... or convention allows me same npm install (from package.json) in r

the packrat package should work use case. if you're using rstudio suggest using packrat tool they've built ui, can use apart rstudio. packrat walkthrough:

## install package cran install.packages("packrat")  ## initialize packrat packrat::init("~/path/to/your/project")  ## later on, install package ## installed in ~/path/to/your/project/packrat/lib install.packages("reshape2")  ## take snapshot of installed packages packrat::snapshot() 

i'm half-way describing manual process. i've ever used automatic mode in rstudio. installed after starting project, , looked through code, managed pull necessary packages (not sure versions, since i'm @ bleeding edge), saved source files, , installed them in project directory. able move packrat directory machine , have install packages.


Comments