<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/reproducibility-a-cautionary-tale-from-data-journalism/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://blog.revolutionanalytics.com/2017/08/reproducibility-a-cautionary-tale.html"> Revolutions</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<div>
<p>Timo Grossenbacher, data journalist with Swiss Radio and TV in Zurich, had a bit of a surprise when he attempted to recreate the results of one of the R Markdown scripts <a rel="nofollow" href="https://srfdata.github.io/" target="_blank">published by SRF Data</a> to accompany their data journalism story about <a rel="nofollow" href="https://github.com/srfdata/2015-07-elections-parliament-lobbying" target="_blank">vested interests of Swiss members of parliament</a>. Upon re-running the analysis in R last week, <a rel="nofollow" href="https://timogrossenbacher.ch/2017/08/this-is-what-happens-when-you-use-different-package-versions-larry/" target="_blank">Timo was surprised when the results differed</a> from those published in August 2015. There was no change to the R scripts or data in the intervening two-year period, so what caused the results to be different?</p>
<div><a rel="nofollow" href="https://timogrossenbacher.ch/2017/08/this-is-what-happens-when-you-use-different-package-versions-larry/" target="_blank"><img border="0" alt="Timo_data" title="Timo_data" src="http://a6.typepad.com/6a0105360ba1c6970c01b7c915b8a6970b-800wi"></a>
<div>Image credit: Timo Grossenbacher</div>
</div>
<p>The version of R Timo was using had been updated, but that wasn't the root cause of the problem. What had <em>also</em> changed was the version of the <a rel="nofollow" href="http://dplyr.tidyverse.org/" target="_blank">dplyr package</a> used by the script: version 0.5.0 now, versus version 0.4.2 then. For some unknown reason, a change in the dplyr package in the intervening package caused some data rows (shown in red above) to be deleted during the data preparation process, and so the results changed.</p>
<p>Timo was able to recreate the original results by forcing the script to run with package versions as they existed back in August 2015. This is easy to do with the <a rel="nofollow" href="http://mran.microsoft.com/documents/rro/reproducibility/" target="_blank">checkpoint package</a>: just add a line like</p>
<p><code>library(checkpoiint); checkpoint(&quot;2015-08-11&quot;)</code></p>
<p>to the top of your R script. We have been taking daily snapshots of every R package on CRAN since September 2014 to address exactly this situation, and the checkpoint package makes it super-easy to find and install all of the packages you need to make your script reproducible, without changing your main R installation or affecting any other projects you may have. (The checkpoint package is <a rel="nofollow" href="https://cran.r-project.org/package=checkpoint" target="_blank">available on CRAN</a>, and also included with all editions of Microsoft R.)</p>
<p>I've been including a call to <code><a rel="nofollow" href="https://www.rdocumentation.org/packages/checkpoint/versions/0.4.1/topics/checkpoint?tap_a=5644-dce66f&tap_s=10907-287229" target="_blank">checkpoint</a></code> on the top of most of my R scripts for several years now, and it's saved me from failing scripts many times. Likewise, Timo has created a structure and process to support truly reproducible data analysis with R, and it advocates using the checkpoint to manage package versions. You can find a description of the process here: <a rel="nofollow" href="https://timogrossenbacher.ch/2017/07/a-truly-reproducible-r-workflow/" target="_blank">A (truly) reproducible R workflow</a>, and <a rel="nofollow" href="https://github.com/grssnbchr/rddj-template" target="_blank">find the template in Github</a>. </p>
<p>By the way, <a rel="nofollow" href="https://srfdata.github.io/" target="_blank">SRF Data</a> — the data journalism arm of the national broadcaster in Switzerland — has published some outstanding stories over the past few years, and has even been <a rel="nofollow" href="http://community.globaleditorsnetwork.org/node/27962" target="_blank">nominated</a> for Data Journalism Website of the Year. At the useR!2017 conference earlier this year, Timo presented several fascinating insights into the data journalism process at SRF Data, which you can see in his <a rel="nofollow" href="http://goo.gl/pF9bKU" target="_blank">slides</a> and talk (embedded below):</p>
<p><iframe width="450" allowfullscreen="" src="https://channel9.msdn.com/Events/useR-international-R-User-conferences/useR-International-R-User-2017-Conference/The-growing-popularity-of-R-in-data-journalism/player" height="288"></iframe></p>
<p>Timo Grossenbacher: <a rel="nofollow" href="https://timogrossenbacher.ch/2017/08/this-is-what-happens-when-you-use-different-package-versions-larry/" target="_blank">This is what happens when you use different package versions, Larry!</a> and <a rel="nofollow" href="https://timogrossenbacher.ch/2017/07/a-truly-reproducible-r-workflow/" target="_blank">A (truly) reproducible R workflow</a></p>
</div>
	<p>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://blog.revolutionanalytics.com/2017/08/reproducibility-a-cautionary-tale.html"> Revolutions</a></strong>.</div>
<hr>
<a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="https://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a rel="nofollow" href="https://www.r-project.org/" title="The R Project for Statistical Computing">R</a> news and <a rel="nofollow" href="https://www.r-bloggers.com/search/tutorial" title="R tutorials">tutorials</a> on topics such as: <a rel="nofollow" href="https://www.r-bloggers.com/search/data%20science" title="Data science">Data science</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Big%20Data" title="Big Data">Big Data, <a rel="nofollow" href="https://www.r-users.com/" title="R jobs">R jobs</a>, visualization (<a rel="nofollow" href="https://www.r-bloggers.com/search/ggplot2" title="ggplot and ggplot2 tutorials">ggplot2</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/boxplot" title="Boxplots using lattice and ggplot2 tutorials">Boxplots</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/map" title="Maps and gis">maps</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/animation" title="Animation in R">animation</a>), programming (<a rel="nofollow" href="https://www.r-bloggers.com/search/RStudio" title="RStudio IDE for R">RStudio</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/sweave" title="Sweave and literate programming">Sweave</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/LaTeX" title="LaTeX in R">LaTeX</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/SQL" title="SQL and databases">SQL</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/eclipse" title="Eclipse IDE for R">Eclipse</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/git" title="git and github, Version Control System">git</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/hadoop" title="Large data in R using Hadoop">hadoop</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/Web+Scraping" title="Web Scraping of google, facebook, yahoo, twitter and more using R">Web Scraping</a>) statistics (<a rel="nofollow" href="https://www.r-bloggers.com/search/regression" title="Regressions and ANOVA analysis tutorials">regression</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/PCA" title="principal component analysis tutorial">PCA</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/time+series" title="Time series">time series</a>, <a rel="nofollow" href="https://www.r-bloggers.com/search/trading" title="finance trading">trading</a>) and more...
<img width="1" alt="" src="http://feeds.feedburner.com/~r/RBloggers/~4/VHulO5bMaq4" height="1"></a></div>