Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

I recently discovered the enigma.io resource, a repository of freely available public with the following goals (as stated on their website):

The volume of data created by governments and businesses is growing exponentially. Organizations struggle just to store it all, let alone make sense of it. Enigma helps organizations and individuals fuse, organize, and explore data to make smarter decisions.​​


It is my intention to start playing around with a lot of the data they have made available, and I figured I would start easy and produce a map of prison locations around the USA (Full disclosure, this is inspired from another post I’ve seen, but I can’t seem to find the original. if you have any idea what I am talking about then please send me the original so I can reference it fairly!).

#### A map of USA prisons

The main point of this post is to illustrate how simple it is to produce interactive leaflet maps using the leaflet and htmlwidgets package in R. in fact, it is only a single line of code to produce the map below, the rest is just processing the data into the correct format. A word of advice when using the leaflet package at the zipcode level: the library expects 5 digits zipcode, while many databases produce zipcodes that sometimes contain 4 digits. If that happens, it is necessary to pad “0”s to the zipcode until the string in question has a length of five. This can be achieved using a neat little trick that is shown in line 11 of the code below!