How to plot country-based choropleths using leaflet R
This will do the trick! Subset the WorldCountry using:
data_Map <- WorldCountry[WorldCountry$id %in% data$Country, ]Map <- leaflet(data_Map) %>% addTiles() %>% addPolygons()
The subset would be with WorldCountry$name
data_Map <- WorldCountry[WorldCountry$name %in% data$Country, ]Map <- leaflet(data_Map) %>% addTiles() %>% addPolygons( fillColor = ~pal(data$Projects), weight = 2, opacity = 1, color = 'white', dashArray = '3', fillOpacity = 0.7, highlight = highlightOptions( weight = 5, color = "#666", dashArray = "", fillOpacity = 0.7, bringToFront = TRUE), label = labels, labelOptions = labelOptions( style = list("font-weight" = "normal", padding = "3px 8px"), textsize = "15px", direction = "auto"))