Reproducible Blogposts

In this blogpost I introduce a rating system for the reproducibility of blogposts, taking authorship, data and code all into account. All blogposts include a star rating at both the top and bottom of the post with a link to (at least) the .Rmd file responsible for generating the page.
Published

February 14, 2018

Writing blogposts that meet all four of these requirements is hard:

In an ideal world, datasets are provided with DOI and/or else easily accessible via an API. If we’re really lucky there’ll be a lovely R package that wraps up the API for us; as is the case for the excellent WDI package that makes the World Bank data available to us. Here’s a nice example of how we can reproducibly obtain and tabulate data using WDI and DT:

library("WDI")
library("tidyverse")
library("DT")

WDI(country=c("DE","NZ"), indicator="IT.NET.USER.ZS", start=2000, end=2001) %>%
  mutate(IT.NET.USER.ZS = IT.NET.USER.ZS / 100) %>%
  datatable(colnames = c("Country Short Code",
                         "Country",
                         "Individuals using the Internet (% of population)",
                         "Year"),
            options = list(dom = "t"),
            height = '100px') %>%
  formatPercentage(columns = 'IT.NET.USER.ZS')

Often times, unfortunately we can’t access data programmatically. Kaggle datasets are a frustrating example of this, there are some really exciting and vibrant datasets published there:

But there is no API for the service, and no direct download link for the data files. This is frustrating as if I write a post using one of these datasets, in order to follow along a reader would have to; manually sign up to Kaggle, download the files, put them in the correct place… and that’s just faff.

What can I do about this? Well, I’m going to do two things:

  1. Use Gists
  2. Rate the reproducibility of my blogposts

Use Gists and reprex

Twitter has been tremendously useful in my learning of #rstats, and folks in the community are incredibly friendly and helpful. So when I was starting up this blog I asked on Twitter for advice on how to make posts reproducible:

A few folks suggested that I use Gists, which is a great service provided by Github for hosting collections of files and code.

I’ve already used Gists before for asking longer form questions on Twitter. It’s definitely a good stop gap for reproducibility where data files aren’t programmatically available and the license allows me to rehost the data (with citation). So in the future, if I use Kaggle datasets (for example) I will rehost the data on Gist along with the code for analysing the data and a link to the original blogpost.

Lastly, whenever I do host code on Gist I’ll use the excellent reprex library which helps guarantee reproducible code samples. reprex is developed by the awesome @jennybryan.

Reproducibility Ratings

I wanted to introduce a way to rate my blogposts in terms of their reproducibility, with the following considerations:

  • Is the author citable?
  • Is the data citable?
  • Is the code citable (and replicable)?

The rating system works as follows:

  • Empty star: Not reproducible — complete lack of unique identifier or programmatic access to resource.
  • Half star: Should be reproducible — a potentially volatile link to the resource has been provided. This includes resources like Gists where commercial interests may make them unavailable in the future. Also includes data accessible via API or CRAN-hosted R packages.
  • Full star: Reliably reproducible — a DOI or other permanent identifier has been given to the resource, future access is highly likely.

For the time being I’m going to be manually adding these components to my posts, but I have a placeholder repository where I’ll package together tools I regularly use for the blog.