Skip to content

Instantly share code, notes, and snippets.

@MrFlick
Last active July 6, 2021 01:27
Show Gist options
  • Save MrFlick/8114a37fcfe6e093570248dad56a5865 to your computer and use it in GitHub Desktop.
Save MrFlick/8114a37fcfe6e093570248dad56a5865 to your computer and use it in GitHub Desktop.
Plotting the world (gapminder data)
library(gapminder)
library(dplyr)
library(ggplot2)
library(ggthemes)
mapdata <- map_data("world") %>%
mutate(region = recode(region,
USA="United States",
UK="United Kingdom"))
gapminder %>%
filter(year==2007) %>%
ggplot() +
geom_map(aes(map_id=country, fill=lifeExp), map=mapdata) +
expand_limits(x = mapdata$long, y = mapdata$lat) +
coord_map(projection = "mollweide", xlim = c(-180, 180)) +
ggthemes::theme_map()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment