Presentation is loading. Please wait.

Presentation is loading. Please wait.

Increasing Reproducibility by Freezing R

Similar presentations


Presentation on theme: "Increasing Reproducibility by Freezing R"— Presentation transcript:

1 Increasing Reproducibility by Freezing R
Jeremy Stephens Vanderbilt Biostatistics Statistical Computing Series November 16, 2012

2 What Is Reproducibility?
Measure of how easy it is to reproduce something To reproduce something, you want to be able to do the same thing you did before.

3 Why Be Reproducible? Decrease job security (j/k) Fewer mistakes
Science! Proof of due diligence If you're the only one that can run your program, you have job security. (just kidding) Hand-entered code on the fly can cause mistakes It's good science.

4 Programming Reproducibility Basics
Saving your code Sharing your tools The most obvious way to be reproducible is by saving your code By sharing the tools you use (R, packages), others can reproduce your work Disk image: Tools image:

5 Saving Your Code Script files Sweave / knitr for reports Packaging
Use script files instead of interactive sessions Use sweave/knitr for reports Create a package

6 Sharing Your Tools R CRAN for packages
R and CRAN and publicly available tools that anyone can use.

7 The problem is change. You can control how and when your own code changes, but the tools you use can change without your consent Image from:

8 When things don't work the same way, it can make you grumpy.

9 But change is good, right?
Maybe. Software changes generally add features and fix bugs, which is good. However, some changes may be unexpected and break code.

10 Freezing R Advantages Insulation from changes Guarantee same behavior
Ability to upgrade when you choose Disadvantages No benefits from bug fixes or new features Harder to share code

11 How? Install multiple versions of R
Set R version to use for each project Local R package directories

12 Renv (pronounced “arr env”)
Command-line tool Lives in your home folder Manage multiple versions of R Switch R versions automatically

13 Renv commands Renv global Renv local Renv shell Renv install

14 Freezing Packages Use project .Rprofile to specify local library path
install.packages() to the local path

15 Workflow for new projects
$ mkdir my_project $ cd my_project $ Renv local $ mkdir .Rlib $ echo ".First <- function() { .libPaths('.Rlib') }" $ R

16 Retrofitting old projects
Find modification time of your code files Install version of R that was active at that time (check out the archive page on CRAN) Install old packages via `R CMD INSTALL`

17 Tips for Upgrading Testing (testthat)
Comparing results (diff, meld, kompare) If you do decide to upgrade your version of R, there are some ways you can make sure everything still works.


Download ppt "Increasing Reproducibility by Freezing R"

Similar presentations


Ads by Google