We start by creating a map of the location.
library(rMaps) L2 <- Leaflet$new() L2$setView(c(29.7632836, -95.3632715), 10) L2$tileLayer(provider = "MapQuestOpen.OSM") L2
We will use the
crime dataset from the
ggmap package that contains a tidied up version of Houston crime data from January 2010 to August 2010.
data(crime, package = 'ggmap') library(plyr) crime_dat = ddply(crime, .(lat, lon), summarise, count = length(address)) crime_dat = toJSONArray2(na.omit(crime_dat), json = F, names = F) cat(rjson::toJSON(crime_dat[1:2]))
Note that it is easy to abstract away these additional steps into a method for the Leaflet class, or an R function that only needs to be provided the data.