You download the data and complete your analysis with ample time to spare. Then, just before deadline, your collaborator lets you know that they've "fixed a data error". Now, you have to do your analysis all over again. This is the reproducibility horror story:
R provides many tools to make reproducibility easy, and the creators of the above video, Ecoinformática - AEET, provide a useful list of tutorials and guides. Chief amongst these is using the knitr package for R: the R language automates the process of importing, preparing and analyzing the data, while knitr automates the process of assembling text, code, tables and charts into a Word, PDF, HTML and many other document formats.
But while knitr solves a good chunk[*] of the reproducibility problem, there's one complicating factor it doesn't deal with: updated R pacakges. In the same way that a collaborator updating the data triggers a restart, someone updating an R package your script uses can also affect your results. (That someone was likely you, working on a different R project.) The checkpoint package for R solves that problem by letting you "lock in" the package versions you use with a project. It's easy to use: all you need to do is add a line like checkpoint("2016-08-31") to the beginning of your script, which:
- Downloads all the packages used by your project (those mentioned files in the current folder), as they were on August 31, 2016
- Installs them in a folder specific to this project (so they're independent from other R projects), and
- Makes sure R uses those package versions when you run your script
It does some clever things to avoid re-downloading packages if it doesn't need to, and avoiding duplicates of multiple copies of the same package version, but that's the basic gist. Checkpoint also makes it really easy to share code with others, because you can be confident they'll also get the packages they need to make your script work. You can learn more about the checkpoint package here and in this vignette, and just install it from CRAN to get started. (If you use Microsoft R Open you don't even need to download it, it's already included.)
[*] pun intended