-
-
Save charliejhadley/9d13ac12a887603b26a1b57342c3d474 to your computer and use it in GitHub Desktop.
R for the Rest of Us - Mapping with R - Disambiguating country names with {countrycode}
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(sf) | |
library(rnaturalearthdata) | |
library(countrycode) | |
library(gapminder) | |
library(mapview) | |
gapminder_2007 <- gapminder %>% | |
filter(year == 2007) | |
gapminder_2007 <- gapminder_2007 %>% | |
mutate(iso_3c = countryname(country, "iso3c")) | |
countries_sf <- countries110 %>% | |
st_as_sf() | |
countries_sf %>% | |
left_join(gapminder_2007, | |
by = c("iso_a3" = "iso_3c")) %>% | |
mapview(zcol = "lifeExp") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment