Interactive Maps with leaflet in R
Rich Majerus
Vice President of Strategy & Planning, Queens University of Charlotte
shp %>%
leaflet() %>%
addTiles() %>%
addPolygons()
shp %>%
leaflet() %>%
addTiles() %>%
addPolygons(weight = 1,
color = "grey",
label = ~paste0("Total Income: " dollar(income)),
highlight = highlightOptions(weight = 3, color = "red",
bringToFront = TRUE))
colorNumeric
nc_pal <- colorNumeric(palette = "Blues",
domain = high_inc@data$mean_income)
colorBin
nc_pal <- colorBin(palette = "YlGn", bins = 5,
domain = high_inc@data$mean_income)
colorQuantile
nc_pal <- colorQuantile(palette = "YlGn", n = 4,
domain = high_inc@data$mean_income)
nc_pal <- colorNumeric("Blues", domain = high_inc@data$mean_income)
previewColors(pal = nc_pal, values = c(seq(100000, 600000, by = 100000)))
nc_pal <- colorNumeric(palette = "Blues", domain = shp@data$mean_income)
shp %>% leaflet() %>% addTiles() %>% addPolygons(weight = 1, fillOpacity = 1, color = ~nc_pal(mean_income), label = ~paste0("Mean Income: ", dollar(mean_income)), highlight = highlightOptions(weight = 3, color = "red", bringToFront = TRUE))
ggplot(shp@data,
aes(mean_income)) +
geom_histogram()
ggplot(shp@data,
aes(log(mean_income))) +
geom_histogram()
Interactive Maps with leaflet in R