Load libraries
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(leaflet)
Load and clean data
volcano <- read.csv("C:/Users/bryan/Downloads/Data Science/Datasets/Random_data/Volcano/volcano_data_2010.csv")
volcano <- select(volcano, Name, Latitude, Longitude, Type)
Create the map
vol_cols <- c("red", "green", "blue", "cyan", "yellow", "magenta")
pal <- colorFactor(palette = vol_cols, domain = volcano$Type)
volcano %>%
leaflet() %>%
addTiles() %>%
addCircleMarkers(lat = volcano$Latitude, lng = volcano$Longitude,
popup = volcano$Name, color = pal(volcano$Type)) %>%
addLegend(labels = levels(volcano$Type), colors = vol_cols)