OpenStreetMapR an R interface to Leaflet

Created by Royalty Analytics

A Cool Example

Here’s a neat example to start with:

## Loading required package: RJSONIO
## Loading required package: tools
df = data.frame(state=sample(unique(map_data("state")$region), 49,replace=F),

#choropleth by state with custom colors assigned to the state
df[["hexColor"]]=sample(rgb(runif(10), runif(10), runif(10)), nrow(df), replace = T)
choroMap = choroplethMap(df, state='state', plotVariable='metric', color="hexColor", layerName = 'States')

#over lay some points and lines
df = data.frame(lat=runif(100, 30,50), long=-runif(100, 70,120), 
                size=runif(100)*20, color=sample(letters[1:3], 100, replace=TRUE),
                group=sample(1:3, 100,replace=TRUE),

pointPlot = OSMMap(df, color='greys', size='size', layer = 'Points',colorByFactor = F)

print(addLayers(choroMap, pointPlot))