Make tilegrams in R with tilegramsR

October 14, 2016
By

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

In this busy election season (here in the US, at least), we're seeing a lot of maps. Some states are red, some states are blue. But there's a problem: voters are not evenly distributed throughout the United States. In this map (the firethirtyeight.com US election forecast on October 13) Montana (MT) is a large state shaded red, but only represents 3 of the 538 Electoral College votes. In the big scheme of things, the outcome in Montana doesn't have much impact on the election. Contrast that with the much smaller state New Jersey with 14 electoral votes: a state so small that its label (NJ) doesn't even fit on the map. A pixel in New Jersey represents almost 80x the voting power of a pixel in Montana, but because of its sheer size Montana dominates on the map. 

538

This wouldn't be a problem if all states had an area directly proportional to the number of Electoral College votes, but that's not the case. But we can fix the problem, and make each state represent its voting power proportionately, by instead using a tiled cartogram, or tilegram. FiveThirtyEight helpfully provides a tilegram of its electoral forecasts as well:

Tilegram

This map gives a much better representative of Clinton's (blue) lead in the race over Trump (red), currently standing at 339 to 199 electoral college votes. 

You can make tilegrams in R, thanks to the tilegramsR package by Bhaskar Karambelkar, and available on Github. Specifically, tilegramR provides spatial objects representing the US states scaled by electoral college votes or population, which you can then use in conjunction with the leaflet package to produce maps (and even add interactivity like pop-up data, if you wish). This RPubs page give several examples of creating tilegrams, inlcuding this map scaled by electoral college votes.

TilegramsR

For more on the tilegramsR package, check out it home on Github linked below.

Github (bhaskarvk): tilegramsR (via FlowingData)

 

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

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.

Sponsors

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)