This page is deprecated. The mapview packages deliveres much of the same functionality, and with less effort. Please explore the introduction to the plotting coordinates with mapview.

library(leaflet)

Leaflet View of Same Map

GreenPalette <- colorNumeric(palette = "Greens",
                               domain = contiguous_states$wages)

contiguous_states %>% 
  st_transform(crs = "+init=epsg:4326") %>%
  leaflet(width = "100%") %>%
  addProviderTiles(provider = "CartoDB.Positron") %>% 
  addPolygons(fillOpacity = 0.7,
              smoothFactor = 0,
              stroke = FALSE, 
              color = ~GreenPalette(wages)) %>% 
  addLegend("bottomleft", 
              pal = GreenPalette, 
              values = ~ wages,
              bins = 5,
              title = "Median Salary - Substance Abuse Social Workers",
              labFormat = labelFormat(prefix = "$"),
              opacity = 1)