The next graph shows the population of Ecuador, the country where I come from, in the year 2017. Please drag your mouse over the map to see the population of each of the provinces:
library(geojsonio)
library(leaflet)
library(dplyr)
provincias <- geojsonio::geojson_read("C:/Users/pdrs8/Desktop/Coursera/Developing Data Products/ecu/ecuador.geojson", what = "sp")
pal <- colorNumeric("viridis", NULL)
leaflet(provincias) %>%
addTiles() %>%
addPolygons(stroke = FALSE, smoothFactor = 0.3, fillOpacity = 1,
fillColor = ~pal(log10(pob_tot)),
label = ~paste0(dpa_despro, ": ", formatC(pob_tot, big.mark = ","))) %>%
addLegend(title = "Population",pal = pal, values = ~log10(pob_tot), opacity = 1.0,
labFormat = labelFormat(transform = function(x) round(10^x)))