data(quakes)
library(leaflet)
## Warning: package 'leaflet' was built under R version 3.2.3
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(htmltools)
##Add A Random Year Column
quakes$year=sample(2006:2015,length(quakes),replace=TRUE)
createMaps<-function(x){
        distinct_by_stations<-distinct(x,stations)
        lflt<-leaflet(data = distinct_by_stations) %>% addTiles() %>% addMarkers(~long,~lat,popup=~as.character(mag))
}

htmltools::tagList(lapply(split(quakes,quakes$year),function(x){createMaps(x)}))