leaflet package, built with
htmlwidgets. Leaflet maps integrate well with the RMarkdown and Shiny ecosystems.
The interface is piped, using a
leaflet() function to initialize a map and subsequent functions adding (or removing) map layers. Many kinds of layers are available, from markers with popups to polygons for creating choropleth maps. Variables in the data.frame passed to
leaflet() are accessed via function-style
To map the
(Screenshot; click for dynamic version.)
library(leaflet) data.frame(state.name, state.center) %>% leaflet() %>% addProviderTiles('Stamen.Watercolor') %>% addMarkers(lng = ~x, lat = ~y, popup = ~state.name, clusterOptions = markerClusterOptions())