Managing R package dependenciesEARL conference was that R is more and more growing out of its academic roots into the enterprise. And with that come some challenges, e.g. how do I ensure consistent and systematic access to a set of R packages in an organisation, in particular when one team is providing packages to others?
Two packages can help here: roxyPackage and miniCRAN.
I wrote about roxyPackage earlier on this blog. It allows me to create a local repository to distribute my package, while at the same time execute and control the build process from within R. But what about my package's dependencies? Here miniCRAN helps. miniCRAN is a new package by Andrie de Vries that enables me to find and download all package dependencies and store them in a local repository, e.g. the one used by roxyPackage.
For more details about roxyPackage and miniCRAN read the respective package vignettes.
ExampleTo create a local sub-CRAN repository for the two packages I maintain on CRAN and with all their dependencies I use:
And to visualise the dependencies:
library("miniCRAN") my.pkgs <- c("googleVis", "ChainLadder") pkgs <- pkgDep(my.pkgs, suggests = TRUE, enhances=FALSE) makeRepo(pkgs = pkgs, path="/Users/Shared/myCRANRepos")
dg <- makeDepGraph(my.pkgs, includeBasePkgs=FALSE, suggests=TRUE, enhances=TRUE) set.seed(1) plot(dg, legendPosEdge = c(-1, 1), legendPosVertex = c(1, 1), vertex.size=20)
What a surprise! In total I end up with 42 packages from CRAN and I didn't expect any connection between the ChainLadder and googleVis package.
Bonus tipDon't miss out on Pat Burns's insightful talk about effective risk management from EARL. His thoughts reminded me of the great Karl Popper: Good tests kill flawed theories; we remain alive to guess again.
R version 3.1.1 (2014-07-10) Platform: x86_64-apple-darwin13.1.0 (64-bit) locale:  en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages:  stats graphics grDevices utils datasets methods  base other attached packages:  miniCRAN_0.1-0 loaded via a namespace (and not attached):  httr_0.5 igraph_0.7.1 stringr_0.6.2 tools_3.1.1  XML_3.98-1.1