====== Map from world map in R / 2 ====== https://github.com/briatte/kmaps > setwd("C:/Users/batagelj/Documents/papers/2018/CRoNoS/shape/nEarth") > library(ggplot2) > library(rgeos) > library(maptools) > gpclibPermit() > library(RColorBrewer) > library(reshape) > library(plyr) > source("../theme.R") > map <- readShapeSpatial("ne_50m_admin_0_countries", proj4string = CRS("+proj=longlat")) > names(map) > map <- rename(map, c(ISO_A2 = "iso2")) #; summary(map) > eco <- subset(read.csv("../iarc.eco.2008.csv", header = TRUE, sep=","), iso2 != "EU27") > dim(eco) #; str(eco) [1] 30 48 > map@data$id <- rownames(map@data) > map.points <- fortify(map, region = "id") > map.df <- join(map.points, map@data, by = "id") > map.df <- join(map.df, eco, by = "iso2") > kmap <- ggplot(map.df) + + coord_cartesian(xlim = c(-24, 46), ylim = c(31, 79)) + + aes(long, lat, group = group) + geom_path(color = "white") + + geom_polygon() + theme_map() > plim <- c(min(eco$mr_m), max(eco$mr_m)) > map.df.missing <- subset(map.df, is.na(mr_m)) > kmap <- kmap + + geom_polygon(data = map.df.missing, aes(long, lat, group = group), fill = "lightgrey") + + scale_fill_gradient("ASR", limits = plim, low = "yellow", high = "red") + + aes(fill = mr_m) > kmap {{notes:da:pics:ecoeu.png}} \\ [[notes:da:ciaeu|Back to CIA Europe data]]