Maps are a powerful tool to show data. As the scope of
igoR
are the InterGovermental Organizations, mapping and
IGOs are a perfect match.
This vignette provides some geospatial visualizations using the IGO datasets (Pevehouse et al. 2020) included in this package. Specific packages used for geospatial data:
giscoR
for extracting the shapefiles of the
countries.ggplot2
for plotting.Also countrycode
is a very handy package for translating
between coding schemes (CoW, ISO3, NUTS, FIPS) and country names.
library(igoR)
# Helper packages
library(dplyr)
library(ggplot2)
library(countrycode)
# Geospatial packages
library(giscoR)
The following maps shows the evolution of countries that are members of the United Nations.
First we should extract the data:
# Extract shapes
<- gisco_get_countries(year = "2010")
world
<- igo_search("UN", exact = TRUE)
un
# Extract three dates - some errors given that ISO doesnt have every COW Code
# Also join with world sf
<-
UN1950 igo_members("UN", 1950) %>%
mutate(ISO3_CODE = countrycode(ccode,
"cown",
"iso3c",
warn = FALSE
%>%
)) left_join(world, .) %>%
mutate(year = 1950) %>%
select(year, orgname)
<-
UN1980 igo_members("UN", 1980) %>%
mutate(ISO3_CODE = countrycode(ccode,
"cown",
"iso3c",
warn = FALSE
%>%
)) left_join(world, .) %>%
mutate(year = 1980) %>%
select(year, orgname)
<-
UN2010 igo_members("UN", 2010) %>%
mutate(ISO3_CODE = countrycode(ccode,
"cown",
"iso3c",
warn = FALSE
%>%
)) left_join(world, .) %>%
mutate(year = 2010) %>%
select(year, orgname)
# Join all
<- bind_rows(UN1950, UN1980, UN2010) UN_all
Note that the map is not completely accurate, as the base shapefile contains the countries that exists on 2016. Some countries, as Czechoslovakia, East or West Germany are not included.
Now we are ready to plot with ggplot2
:
ggplot(UN_all) +
geom_sf(aes(fill = orgname), color = NA, show.legend = FALSE) +
# Robinson
coord_sf(crs = "ESRI:54030") +
facet_wrap(vars(year),
ncol = 1,
strip.position = "left"
+
) scale_fill_manual(
values = "#74A9CF",
na.value = "#E0E0E0"
+
) theme_void() +
labs(
title = "UN Members",
caption = gisco_attributions()
+
) theme(plot.caption = element_text(face = "italic"))