you complicated it a little.
See that you need to create a booklet and apply markers on top of it, choosing longitudes and latitudes from unique stations.
But here you create flyers in a loop. As well as adding tiles to the loop, which is the main problem.
Now you can create a flyer and addTiles from a loop and addMarkers in a loop, but you really don't need a for loop and add all the markers at a time.
First select a dataset using unique stations
distinct_by_stations<-distinct(quakes,stations)
Create a booklet and add markers using the above filter data as data
leaflet(data = distinct_by_stations) %>% addTiles() %>% addMarkers(~long,~lat,popup=~as.character(mag))
See working .rmd here, rpubs
http://rpubs.com/dhawalkapil/quakesdata
Worker R Chunk
```{r quakes, echo=T} data(quakes) library(leaflet) library(dplyr) distinct_by_stations<-distinct(quakes,stations) leaflet(data = distinct_by_stations) %>% addTiles() %>% addMarkers(~long,~lat,popup=~as.character(mag)) ```
With multiple cards
Add a column of years. Then we will have to use htmltools::tagList , as explained by @NicE. Separate "year" and use lapply
```{r quakes, echo=T,results='asis'} data(quakes) library(leaflet) library(dplyr) 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)})) ```
See rpubs updates in the same url above.