Introduction

Leaflet is one of the most popular Javascript libraries for creating interactive maps. The leaflet R package allows you to create your own

library(leaflet)
my_map <- leaflet() %>% 
  addTiles()
my_map

My First Map

library(leaflet)
my_map <- my_map %>%
  addMarkers(lat=37.5663, lng=-126.9779, popup="Seoul City Hall")
my_map

Mapping Clusters

df <- data.frame(lat = runif(50, min = 37.54, max = 37.56),
                 lng = runif(50, min = 126.90, max = 126.97))
## Warning in runif(50, min = 37.54, max = 37.56): '.Random.seed' is not an
## integer vector but of type 'NULL', so ignored
df %>% 
  leaflet() %>%
  addTiles() %>%
  addMarkers(clusterOptions = markerClusterOptions())