Load all the shapefiles into one spatial object

library(sf)
library(rgdal)
library(raster)
library(leaflet.extras)
library(dplyr)
fls<-dir(path="/home/rstudio/markus/shapefiles", pattern="*shp$")
fls<-sprintf("/home/rstudio/markus/shapefiles/%s",fls)
f1<-sf:::read_sf(fls[1])
library(mapview)
f<-function(x){
  out<-read_sf(x)
  out<-out[,c("MALE","geometry")]
  out$filename<-x
  out

}
territories<-lapply(fls,f)
d<-do.call("rbind",territories)
d$year<-gsub("[^0-9]","",d$filename)
d$year<-as.numeric(d$year)

View

As the number of years would lead to a confusing map if I plotted all together I’ll separate them into blocks.

Up to 2010

Go full screen and select years to view.

d %>% filter(year<2010) %>%
mapview(zcol="year",burst=TRUE) ->m
m@map %>% addFullscreenControl()

2010 and later

Go full screen and select years to view.

d %>% filter(year>2009) %>%
mapview(zcol="year",burst=TRUE) ->m
m@map %>% addFullscreenControl()