# NOT RUN {
library(sp)
data(nuts2006)
# Get borders
nuts0.contig <- getBorders(x = nuts0.spdf)
# GDP per capita
nuts0.df$gdpcap <- nuts0.df$gdppps2008/nuts0.df$pop2008
# Plot countries
plot(nuts0.spdf, col="#CCCCCC", lwd=1, border="white")
# Plot discontinuities
discLayer(x = nuts0.contig, df = nuts0.df,
var = "gdpcap", col="red", nclass=5,
method="quantile", threshold = 0.5, sizemin = 1,
sizemax = 10, type = "rel", legend.frame = TRUE,
legend.title.txt = "GDP per Capita discontinuities\n(relative)",
legend.pos = "topright", add=TRUE)
library(sf)
mtq <- st_read(system.file("shape/martinique.shp", package="cartography"))
# Get borders
mtq.borders <- getBorders(x = mtq)
# Employees share in the pop
mtq$emp_share <- 100 * mtq$C13_CS5/mtq$C13_POP
# Plot this share
choroLayer(x = mtq, var = "emp_share", border = NA, method = 'q6',
legend.values.rnd = 1, legend.pos = "topleft",
legend.title.txt = "Share of employees\nin the population\n(age > 15 y.o.)" )
# Plot discontinuities
discLayer(x = mtq.borders, df = mtq,
var = "emp_share", col="darkorange2", nclass=3,
method="quantile", threshold = 0.5, sizemin = 0.5,
sizemax = 10, type = "abs",
legend.title.txt = "Discontinuities\n(absolute difference)",
legend.pos = "bottomleft", add=TRUE)
# }
Run the code above in your browser using DataLab