#Session 7 Mapping WORLD BANK ECONOMIC REGIONS
#collecting the data
linkCSV='https://github.com/pubpolicy/PubPolicy-543/raw/main/gbdChildMortality_2010s.csv'
dataCSV=read.csv(linkCSV)
str(dataCSV)
## 'data.frame': 187 obs. of 12 variables:
## $ iso : Factor w/ 187 levels "AFG","AGO","ALB",..: 1 2 3 4 5 6 7 8 9 10 ...
## $ NAME_EN : Factor w/ 187 levels "Afghanistan",..: 1 5 2 4 177 7 8 6 9 10 ...
## $ gbdRegion : Factor w/ 21 levels "Asia Pacific, High Income",..: 4 18 8 10 15 13 2 7 6 10 ...
## $ year : int 2010 2010 2010 2010 2010 2010 2010 2010 2010 2010 ...
## $ neoMR : num 56.03 37.33 3.66 2.98 2.4 ...
## $ postneoMR : num 35.76 47.03 8.31 1.42 0.5 ...
## $ age1_5MR : num 34.66 56.93 3.24 0.46 0.09 ...
## $ under5MR : num 121.33 134.83 15.14 4.86 2.98 ...
## $ neoDeaths : int 74870 29747 173 3 153 5659 555 49 749 170 ...
## $ postneoDeaths: int 45189 36539 394 1 32 2637 276 31 413 95 ...
## $ age1_5Deaths : int 40945 41858 153 0 7 676 106 14 133 31 ...
## $ under5Deaths : int 161004 108143 720 5 192 8972 937 94 1295 297 ...
location="https://github.com/pubpolicy/PubPolicy-543/raw/main/"
file="WB_countries_Admin0_10m.json"
linkToFile=paste0(location,file)
# import
library(sf)
## Warning: package 'sf' was built under R version 3.6.3
## Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
mapWorld=read_sf(linkToFile)
mapWorldVars=merge(mapWorld, #map first
dataCSV,
by.x='ISO_A3', by.y='iso')
library(ggplot2)
# plot original map
base=ggplot(data=mapWorld) + geom_sf(fill='grey90',
color=NA) + theme_classic()
base #base map
titleText='Distribution of countries by World Bank Economy Classification'
sourceText='Source: World Bank'
colMap= base + geom_sf(data=mapWorldVars,
aes(fill=ECONOMY),
color=NA) + labs(title=titleText,
x =NULL,
y = NULL,
caption = sourceText)
colMap