Make tilegrams in R with tilegramsR

[This article was first published on Revolutions, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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 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. 


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:


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.


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. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)