Ensure R Language Reproducibility with dateback Package

Sooner or later, most R programmers end up with code that no longer runs because of package updates. One way to address the problem was the MRAN Time Machine which Microsoft retired on July 1, 2023. You can get similar functionality for source packages using “dateback,” thanks to Ryota Suzuki. As with MRAN, examples of when you could benefit from using dateback include:

  • Checking the reproducibility of old code without pre-archived R packages.
  • Returning your code to an older state when everything was fine.
  • Needing to work on an older version of R, on which recent versions of some packages do not work properly (or cannot be installed) due to compatibility issues.
  • Needing source package files to make a Docker image stable and reproducible, especially when using an older version of R.

Let’s consider an example. There are three options to install a source package, “ranger.”

Using CRAN:

install.packages("ranger", 
  repos = "https://cloud.r-project.org", type = "source")

Using MRAN Time Machine:

install.packages("ranger", 
  repos = "https://cran.microsoft.com/snapshot/2023-03-01/", 
  type = "source")

Using dateback (with CRAN):

dateback::install("ranger", date = "2023-03-01", 
  repos = "https://cloud.r-project.org")

They ALL get “ranger” and its dependencies (Rcpp and RcppEigen). The differences are:

  • CRAN provides the latest versions, some of which were released AFTER 2023-03-01 (ranger 0.15.1 released on 2023-04-03, and Rcpp 1.0.11 released on 2023-07-06).
  • With MRAN Time Machine, we could get the desired versions (ranger 0.14.1 released on 2022-06-18, and Rcpp 1.0.10 released on 2023-01-22). We could also get the binary versions, but the site is now shut down.
  • dateback gets basically the same versions as MRAN Time Machine, including dependencies (some may slightly differ since we don’t have the exact snapshot of CRAN, but they should be almost identical).

Of course, we can manually search on CRAN and find desired versions. But it makes a huge difference when we install a package with many complicated dependencies (like a package X depends on Y and Z, Y depends on P and Q, and so on). The number of packages needed can run into the dozens. With dateback, you don’t need to worry about what they are or how many.

Ryota is also the lead developer for R AnalyticFlow, the only workflow-style graphical user interface for R. You can download that for free here and read my review of it here. How it compares to other R GUIs is summarized here. Thanks to Ryota for most of the information in this post!

One thought on “Ensure R Language Reproducibility with dateback Package”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.