Skip to content

Instantly share code, notes, and snippets.

@USMortality
Last active July 21, 2025 16:54
Show Gist options
  • Save USMortality/d737f3c3df24d76e61e0e01128104510 to your computer and use it in GitHub Desktop.
Save USMortality/d737f3c3df24d76e61e0e01128104510 to your computer and use it in GitHub Desktop.
Population per Medal in the Olympic Games since 1896 [World]
library(readr)
library(ggplot2)
library(scales)
library(dplyr)
sf <- 2
width <- 600 * sf
height <- 335 * sf
options(vsc.dev.args = list(width = width, height = height, res = 72 * sf))
df <- read_csv(
"https://apify.mortality.watch/olympics-medals.csv"
)
de <- df |> filter(country == "Germany")
mean(de$population_per_medal)
median(de$population_per_medal)
chart <- df |>
filter(country %in% c(
"Germany", "United States", "China", "Great Britain", "France"
)) |>
ggplot(aes(x = year, y = population_per_medal, color = country)) +
geom_line() +
labs(
x = "Year", y = "Population per Medal",
title = "Population per Medal in the Olympic Games",
subtitle = "Source: medalspercapita.com"
) +
scale_y_log10(labels = label_number(accuracy = 1))
ggplot2::ggsave(
filename = "chart1.png", plot = chart, width = width, height = height,
units = "px", dpi = 72 * sf, device = grDevices::png, type = c("cairo")
)
@USMortality
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment