Who Came Second in the UK Election?

May 8, 2015

(This article was first published on R on kieranhealy.org , and kindly contributed to R-bloggers)

The UK’s election results are being digested by the chattering classes. So, yesterday afternoon I thought I’d see if I could grab the election data to make some pictures. Because the BBC has sane HTML structure, this proved a lot more straightforward than I feared—thanks in no small part to Hadley Wickham’s rvest scraping library together with ggplot and dplyr and all the other tools he’s contributed to the R-using public.

So I grabbed the data and made some pictures. Here are two maps. The first is a version of the one you’ve seen showing the winning party in every constituency in Great Britain (sic: excluding Northern Ireland).

Constituencies by Winning Candidate.

British Constituencies by Winning Candidate.

The SNP sweep in Scotland, the solid Tory South, the Labour strongholds in parts of London, the Midlands, Northern England, and South Wales. You’ve seen this one already.

Here’s an alternative map. It shows the results with constituencies colored by the second-place candidate.

Constituencies by Runner-Up Candidate.

British Constituencies by Runner-Up Candidate.

It’s eye-opening, I think. The UK has a First-Past-the-Post election system, which means—to those of us raised on PR-STV—that there’s a fairly substantial discrepancy between vote share and seats. A consequence is that the electoral base of smaller parties—as opposed to their effective political strength—is easy to underestimate just from a winner’s map. In many constituencies, of course, the race was straightforwardly between the two largest parties. It’s Tories vs Labour, with one winning and the other coming in second. But that’s by no means the only story. In the Runners-Up map, Scotland looks more varied than before, and you can see the memory of Lloyd George in Wales. Meanwhile the South coast, Thames Estuary, and the East of England are also quite striking, as a sea of Tory blue gives way to Lib-Dems and UKIP support.

There’s plenty more you could do with this data. The code to produce the maps (and scrape the numbers, if you’d like) is on Github.

To leave a comment for the author, please follow the link and comment on their blog: R on kieranhealy.org .

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)