Interactive Maps with leaflet in R
Rich Majerus
Vice President of Strategy & Planning, Queens University of Charlotte
ipeds %>%
filter(state == "ME")
# A tibble: 21 x 5
name lng lat state sector_label
<chr> <dbl> <dbl> <chr> <chr>
1 Bates College -70.20333 44.10530 ME Private
2 Bowdoin College -69.96524 43.90690 ME Private
3 Colby College -69.66337 44.56421 ME Private
4 College of the Atlantic -68.22885 44.39958 ME Private
...
# Assuming 'lng' and 'lat' are longitude and latitude, respectively
maine_colleges_map <-
leaflet() %>%
addProviderTiles("CartoDB") %>%
addMarkers(data = maine_colleges)
maine_colleges_map <-
leaflet() %>%
addProviderTiles("CartoDB")%>%
addMarkers(data = maine)
# adding more markers will
# not remove existing markers
maine_colleges_map %>%
addCircleMarkers(data = maine)
# adding more markers will
# not remove existing markers
maine_colleges_map %>%
addCircleMarkers(data = maine)
maine_colleges_map %>%
clearMarkers() %>%
addCircleMarkers(data = maine,
radius = 3)
maine_colleges_map <-
maine_colleges_map %>%
clearMarkers %>%
addCircleMarkers(
data = maine_colleges,
radius = 3)
maine_colleges_map %>%
addCircleMarkers(
data = maine_colleges,
radius = 4,
color = "red",
popup = ~name)
Interactive Maps with leaflet in R