# NOT RUN {
## Example 1
library(sp)
data("nuts2006")
nuts2.df$unemprate <- nuts2.df$unemp2008/nuts2.df$act2008*100
choroLayer(spdf = nuts2.spdf,
           df = nuts2.df,
           var = "unemprate")
## Example 2
nuts2.df$unemprate <- nuts2.df$unemp2008/nuts2.df$act2008*100
choroLayer(spdf = nuts2.spdf,
           df = nuts2.df,
           var = "unemprate",
           method = "quantile",
           nclass = 8,
           col = carto.pal(pal1 = "turquoise.pal", n1 = 8),
           border = "grey40",
           add = FALSE,
           legend.pos = "topright",
           legend.title.txt = "Unemployement rate\n(%)",
           legend.values.rnd = 1)
## Example 3
library(sf)
mtq <- st_read(system.file("shape/martinique.shp", package="cartography"))
# Compute the compound annual growth rate
mtq$cagr <- (((mtq$P13_POP / mtq$P08_POP)^(1/4)) - 1) * 100
summary(mtq$cagr)
# Plot the compound annual growth rate
cols <- carto.pal(pal1 = "blue.pal", n1 = 3, pal2 = "red.pal", n2 = 2)
choroLayer(x = mtq, 
           var = "cagr", breaks = c(-6.14,-2,-1,0,1,2),
           col = cols,
           border = "grey40",
           add = FALSE,
           legend.pos = "topleft",
           legend.title.txt = "Compound annual\ngrowth rate",
           legend.values.rnd = 2)
# Layout plot
layoutLayer(title = "Demographic Trends in Martinique, 2008-2013",
            author = "INSEE, 2016", sources = "",
            scale = NULL,
            frame = TRUE,
            col = "black",
            coltitle = "white")
# }
Run the code above in your browser using DataLab