Skip to content

2. Reproducible Package Ecosystem

Jonathan Carroll edited this page Oct 23, 2018 · 1 revision

Why Use A Reproducible Package Ecosystem?

R packages are regularly (or semi-regularly) updated to include new features, new implementations, better compatability with other packages, and bug fixes. Occasionally this changes the way the user interacts with the packages' functions. This makes versioning extremely important.

switchr

In order to guarantee that the code you run works exactly the same as I have written in Beyond Spreadsheets with R, I've included a method by which you can -- regardless of their current state -- install the exact same versions of the required packages as I used. In order for this to work, I've leveraged the switchr package. You can install the stable version of this with

install.packages("switchr")

within an R session.

Beyond Spreadsheets with R switchr Manifest

The switchr manifest BeyondSpreadsheetsManifest.rds details 120 packages (those used for the book and their dependencies) to be installed, and their specific versions. They are:

Click to expand...
A seeding manifest (SessionManifest object)

Describes a cohort of 120 package versions. 
120 packages are listed in the underlying package manifest

Package versions:
         name  version
   assertthat    0.2.0
    backports    1.1.2
    base64enc    0.1-3
           BH 1.65.0-1
        bindr      0.1
     bindrcpp      0.2
         brew    1.0-6
        broom    0.4.3
        callr    1.0.0
   cellranger    1.1.0
          cli    1.0.0
        clipr    0.4.0
   colorspace    1.3-2
   commonmark      1.4
       crayon    1.3.4
    crosstalk    1.0.0
         curl      3.1
   datasauRus    0.1.2
   data.table 1.10.4-3
          DBI      0.7
       dbplyr    1.2.0
         desc    1.1.1
     devtools   1.13.4
    dichromat    2.0-0
       digest   0.6.14
        dplyr    0.7.4
     evaluate   0.10.1
      forcats    0.2.0
      ggplot2    2.2.1
        git2r   0.21.0
         glue    1.2.0
    gridExtra      2.3
       gtable    0.2.0
        haven    1.1.1
         here      0.1
        highr      0.6
          hms    0.4.0
    htmltools    0.3.6
  htmlwidgets      1.0
       httpuv    1.3.5
         httr    1.3.1
     jsonlite      1.5
        knitr     1.18
     labeling      0.3
     lazyeval    0.2.1
      leaflet    1.1.0
    lubridate    1.7.1
     magrittr      1.5
      mapproj    1.2-5
         maps    3.2.0
     markdown      0.8
      memoise    1.1.0
         mime      0.5
       misc3d    0.8-4
       mnormt    1.5-5
       modelr    0.1.1
      munsell    0.4.3
      openssl    0.9.9
     openxlsx   4.0.17
       pillar    1.1.0
    pkgconfig    2.0.1
        plogr    0.1-1
       plot3D    1.1.1
         plyr    1.8.4
          png    0.1-7
       praise    1.0.0
        psych    1.7.8
        purrr    0.2.4
           R6    2.2.2
       raster    2.6-7
 RColorBrewer    1.1-2
         Rcpp  0.12.15
        readr    1.1.1
       readxl    1.0.0
      rematch    1.0.1
       reprex    0.1.1
     reshape2    1.4.3
          rex    1.1.2
          rio    0.5.5
        rlang    0.1.6
    rmarkdown      1.8
     roxygen2    6.0.1
    rprojroot    1.3-2
   rstudioapi      0.7
        rvest    0.3.2
       scales    0.5.0
      selectr    0.3-1
        shiny    1.0.5
  sourcetools    0.1.6
           sp    1.2-7
      stringi    1.1.6
      stringr    1.2.0
     testthat    2.0.0
       tibble    1.4.1
        tidyr    0.7.2
   tidyselect    0.2.3
    tidyverse    1.2.1
         utf8    1.1.3
      viridis    0.4.1
  viridisLite    0.2.0
      whisker    0.3-2
        withr    2.1.1
         xml2    1.1.1
       xtable    1.8-2
         yaml   2.1.16
         boot   1.3-19
        class   7.3-14
      cluster    2.0.6
    codetools   0.2-15
      foreign   0.8-67
   KernSmooth  2.23-15
      lattice  0.20-35
         MASS   7.3-47
       Matrix   1.2-10
         mgcv   1.8-17
         nlme  3.1-131
         nnet   7.3-12
        rpart   4.1-11
      spatial   7.3-11
     survival   2.41-3

Download the manifest file to your computer.

Switching to The Reproducible Package Ecosystem

Enter the following R code into your Console. Change the path to reflect where you saved the manifest file.

BeyondSpreadsheetsManifest <- readRDS("/path/to/BeyondSpreadsheetsManifest.rds")
switchTo("BeyondSpreadsheets", seed = BeyondSpreadsheetsManifest)

This should then install all of the required packages into a special library which you can switch to at any time. This may take some time, depending on your internet connection, and a lot of text is going to go scrolling past. Don't be frightened if you see the occasional error message, such as

Failed with error:  ‘there is no package called ‘RCurl’’

When you're done with the book examples, you can switch back to your normal R package library using

switchBack()

The next time you wish to again work with this special library, you can switch to it with just

library(switchr)
switchTo("BeyondSpreadsheets")