townsendr interactive map

[This article was first published on rstats –, 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.

This week I updated my Townsend Material Deprivation Score project. The update makes townsendr an interactive online map of deprivation that users can simply view in their browser, rather than having to download and run the R code or view only static maps. I think the result is much more intuitive and useful. Making the map interactive is achieved by using Shiny, a technology for R to make interactive charts and plots. As well as this, the maps are now rendered by leaflet rather than ggplot2. ggplot2 is an awesome technology for making beautiful charts in R, but leaflet is a javascript library designed specifically for plotting interactive maps so rendering the map is now so effortless it felt like cheating.

The data is based on the relevant census tables obtained from Nomis. The shapefiles are obtained from the UK Data Service, but are greatly simplified (even the generalised versions were about 5MB, much too big for interactive use). Both are available under open licenses. For more information see the townsendr web page or the GitHub repository. Pull requests are very welcome.

I’m really happy with the result, which is my first attempt using Shiny and leaflet, but there’s more work to do (when I have time!). Specifically I think the following need addressing:

  • London probably needs removing from the analyses because car ownership and home ownership are low in London even among households that aren’t deprived.
  • The colour scale needs more contrast between high and low deprivation (although this might be corrected by removing London!). I might even create bands that show quantiles of deprivation.
  • The legend needs improving, specifically it should be clearer that darker blue = more deprivation. The z-scores probably aren’t that useful to someone who doesn’t know what they signify.

If you notice anything else, fix it and submit a pull request or file an issue for me to address!

To leave a comment for the author, please follow the link and comment on their blog: rstats – 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)