Created
November 30, 2022 22:47
-
-
Save MattCowgill/93079c16d6fea8d4c9798bb27b326627 to your computer and use it in GitHub Desktop.
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(readxl) | |
library(tidyverse) | |
library(geomtextpath) | |
library(seektheme) | |
library(patchwork) | |
madd_url <- "https://www.rug.nl/ggdc/historicaldevelopment/maddison/data/mpd2020.xlsx" | |
madd_file <- tempfile(fileext = ".xlsx") | |
download.file(madd_url, madd_file, mode = "wb") | |
madd_data <- read_excel(madd_file, sheet = "Full data") | |
oz_arg <- madd_data |> | |
filter(country %in% c("Argentina", | |
"Australia")) |> | |
filter(!is.na(gdppc), | |
year >= 1850) | |
plot_level <- oz_arg |> | |
ggplot(aes(x = year, y = gdppc, col = country)) + | |
geom_linepoint(linewidth = 1, | |
size = 18 / .pt) + | |
geom_finallabel(aes(label = paste0(country, "\n", | |
scales::dollar(gdppc, 1))), | |
nudge_x_perc = 3) + | |
scale_y_continuous(labels = scales::dollar) + | |
scale_x_continuous(expand = expansion(c(0, 0.27)), | |
breaks = c(seq(1800, 2000, 50), | |
max(madd_data$year)), | |
labels = \(x) ifelse(x == 2018, "'18", x)) + | |
theme_seek() + | |
theme(axis.title = element_blank(), | |
legend.position = "element_blank()") + | |
labs(subtitle = "Real GDP per capita") | |
plot_ratio <- oz_arg |> | |
select(country, year, gdppc) |> | |
pivot_wider(names_from = country, | |
values_from = gdppc) |> | |
mutate(ratio = Argentina / Australia) |> | |
ggplot(aes(x = year, y = ratio)) + | |
geom_line(colour = seek_grey_1) + | |
theme_seek() + | |
scale_y_continuous(labels = scales::percent, | |
expand = expansion(0.1)) + | |
scale_x_continuous(breaks = c(seq(1800, 2000, 50), | |
max(madd_data$year)), | |
labels = \(x) ifelse(x == 2018, "'18", x)) + | |
theme(axis.title = element_blank()) + | |
labs(subtitle = "Argentina's real GDP per capita as a percentage of Australia's") | |
plot_level + | |
plot_ratio + | |
plot_annotation(caption = "Source: Maddison Project database.", | |
theme = theme_seek()) | |
seek_save_image("argie.png", | |
width = 25, | |
height = 15) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment