11  Using Data From rnaturalearth

11.1 Call Libraries

Show the code
library(rnaturalearth) # natural earth data

library(ggplot2) # beautiful maps

library(dplyr) # data wrangling

library(sf) # simple (spatial) features

11.2 Get ne_countries As sf

Show the code
ne_countries <- ne_countries(scale = "medium", 
                             returnclass = "sf") 

11.3 Map

Show the code
ggplot(ne_countries) + 
  geom_sf(aes(fill = income_grp)) +
  scale_fill_viridis_d(name = "Income Group", 
                       option = "viridis") +
  labs(title = "Countries of the World") +
  theme_minimal()