Announcing the R Election Analysis Contest

Today I am happy to announce the R Election Analysis Contest. The goal of the contest is to encourage and promote high quality reproducible research in R that focuses on elections. The winner will be featured on my blog and receive a free copy of my course Mapmaking in R with Choroplethr as well as a copy of Hadley Wickham’s book Advanced R.

Why a contest?

As I write this, the US Presidential Primary is dominating the news. What strikes me about the news is how analytical the discussion is. Major themes seem to be:

  • The demographics of each voting region
  • How different demographics are attracted to each party
  • How different demographics are attracted to each candidate within each party
  • How the above change over time
  • The math behind delegates and winning both primary nominations and general elections

A major interest I have is using R to verify claims that I hear in the media. I’ve been wanting to explore voting related issues in R for a while now. And when I read pieces by Julia Silge (1, 2, 3) and Duncan McIntosh (1) I see that I am not alone.

Rather than spending a week or two on my own analysis, I think that it would be better to run a contest. If the contest gets even a modest number of entries, then I will probably enjoy reading them more than I would enjoy writing my own.

How do I enter?

To be considered, your entry must:

  1. Be published online by Saturday April 16, 2016. If you have a blog, you can publish it there. You can also use rPubs, which is free.
  2. Leave a comment on this page with a description and link to your entry. I will personally read each entry.
  3. Your entry must contain an analysis that is both written in R and reproducible. That is, you must write code that works and use data that other people can load. Think of yourself as both writing an analysis and teaching other people how you did it.
  4. Winners will be announced on my blog on Monday, April 18 2016.


  1. Can I submit more than one analysis? Sure.
  2. Can I analyze an election other than the 2016 US Presidential election? Sure. It can be about a past election, an election for another office, or even an election in another country.
  3. Can I enter as a group? Sure. In the case that a group wins all members will get a free copy of Mapmaking in R with Choroplethr. But I can only afford to buy one copy of Advanced R.
  4. Do you have any ideas for analyses to do? Yes, but I’d rather not share them. I’m certain that someone reading this has an interesting idea that I haven’t even considered. I’d rather encourage that person to publish and submit their own analysis.
  5. How can I get in touch with you? Via twitter or email.
  6. How can I support the contest? Click the “share” buttons on this page to share it with your friends. Or click the button below to tweet about it:
[bctt tweet=”Announcing the R Election Analysis Contest #rstats #ddj #opendata”]


gabrielk says March 28, 2016


    Ari Lamstein says March 28, 2016

    Thank you! I hope that you decide to submit an analysis!

    Ari Lamstein says March 29, 2016

    Great work! Congrats on being the first submission!

Karim L says March 28, 2016

How exciting! I will do my best…

    Ari Lamstein says March 28, 2016

    I look forward to your submission!

Chris Hanning says March 29, 2016

This is not mine but is interesting:

Alexander Podkul says March 30, 2016

Here’s a quick analysis I mocked up – hopefully I’ll get around to making another submission!

    Ari Lamstein says March 30, 2016

    Great entry! I l was not aware that donation data was publicly available at all, let alone at the county level!

yoni sidi (@yoniceedee) says March 30, 2016

Hi I got a message from Tal about submitting to the contest. Where do I do it? I can submit both election apps 🙂

    Ari Lamstein says March 31, 2016

    Great! To enter just leave a comment on this blog post with a link to your entries!

      yoni sidi (@yoniceedee) says April 19, 2016

        yoni sidi (@yoniceedee) says April 19, 2016

        this is the israeli election app. it has more stat features (bootstrapping the mandates distributions using sampling errors and user built government coalitions based on real and resampled results) than the USA one

james igoe says March 31, 2016

I am an R, as well as statistics, novice, and do not have an formal accreditation other than the usual tertiary education, but have always enjoyed working with statistics and data. Recently, I’ve started exploring both R and Python on old data sets I considered trying to publish about. Anyway, here are my entries:

Chi-Square in R on by State Politics (Red/Blue) and Income (Higher/Lower):

Decision Tree in R, with Graphs: Predicting State Politics from Big Five Traits:

Logistic Regression in R on Politics and Income:

    Ari Lamstein says March 31, 2016

    Great! Thank you!

    Ari Lamstein says March 31, 2016

    Can you update your entries to say where the data comes from, and provide a link to the source of the data?

d sparks says April 1, 2016

Here is a post detailing how to plot Congressional ideology over time:

The same blog has several posts on mapping with R, for example:
Mapping the Gerrymander:
Dot density maps of electoral returns:

Peter Ellis says April 2, 2016

Great contest, motivated me to get started on something I’ve thought of for a while… I’ve started my entry here:

I’ll be doing two or three additional posts, you can consider them as separate entries or the whole thing as a single entry with parts (which is probably more the way I’m thinking of it). I’m creating a new R package to give convenient access to New Zealand general election results, doing some sample analysis and a Shiny app, and hopefully will get onto some real analysis of spatial trends in voting behavior.

    Ari Lamstein says April 4, 2016

    Great! I look forward to your next entry!

      Peter Ellis says April 8, 2016

      My second ‘entry’ is really an extension of the first, going into more detail of how the R package was built, and is at . The third and (hopefully) fourth will be more stand alone bits of analysis!

Julia Silge says April 8, 2016

I had one more bit of election analysis I wanted to do, so I have a new post here on voter turnout in Utah’s caucuses this election cycle:

    Ari Lamstein says April 8, 2016

    Thank you!

Peter Ellis says April 8, 2016

Next in my series – this time looking at micro-spatial contrasts between selected parties in selected locations, and creating a leaflet/shiny app for others to explore

    DANIEL MENDOZA says April 10, 2016

    Clearly we have a winner.

Karim L says April 13, 2016

Hi Ari, hi everyone.
My modest entry here:
Cheers !

DANIEL MENDOZA says April 14, 2016

An analysis of tweets directed to Mr. Trump and those originating from his own twitter.
Link to the report:

Because of the amount of time it took search twitter for tweets directed towards Mr. Trump I am also including a data frame with these tweets:

    Karim L says April 14, 2016

    @Daniel I am loving your report !!

Karim L says April 14, 2016

@Daniel your report is fascinating !

    Karim L says April 14, 2016

    Sorry for the unintended double post. Could you provide some pointers as to how to get a developer’s key ?

      Karim L says April 14, 2016

      Never mind, all set ! [/endspam]

      DANIEL MENDOZA says April 15, 2016

      No worries Karmin, I am glad you love the post and hopefully you like some of the additional analysis I plan to do on the data.
      In order to get a developer’s key point your browser over to:
      Create an app and plug away into you get an API_key and a secret_key. One thing to note, the documentation instructs that you set the callback URL to

Peter Ellis says April 15, 2016

My final entry, or component of my multi-part entry, however you want to treat it, now available at

Alexander Podkul says April 16, 2016

One last entry! Looking at the accuracy of the primary polls in the 2016 GOP Primaries.

vijayvithal jahagirdar says April 17, 2016
My analysis of the BBMP elections that took place last year in Bangalore, India

Comments are closed