Interactive Maps with leaflet in R
Rich Majerus
Vice President of Strategy & Planning, Queens University of Charlotte
OR <- ipeds %>% filter(state == "OR")
pal <- colorFactor(palette = c("red", "blue", "#9b4a11"), levels = c("Public", "Private", "For-Profit"))
oregon_colleges <- OR %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(radius = 2,
color = ~pal(sector_label), label = ~name)
oregon_colleges %>%
addLegend(position = "bottomright",pal = pal,
values = c("Public", "Private", "For-Profit"))
admit <- admit %>%
filter(!is.na(rate),rate < 50, rate > 0)
pal <- colorNumeric(palette = "Reds", domain = c(1:50),
reverse = TRUE)
admit_map <- admit %>%
leaflet() %>%
addProviderTiles("CartoDB") %>%
addCircleMarkers(radius = 4, color = ~pal(rate),
label = ~name) %>%
addLegend(title = "Admit Rate", pal = pal, values = c(1:50),
position = "bottomright")
# see https://colorbrewer2.org/ for interactive examples
library(RColorBrewer)
display.brewer.all()
Interactive Maps with leaflet in R