Population, Total - SP.POP.TOTL

Data - WDI

Info

LAST_DOWNLOAD

Code
tibble(dataset = c("SP.POP.TOTL", "NY.GDP.MKTP.KD.ZG", "NY.GDP.MKTP.CD")) %>%
  mutate(LAST_DOWNLOAD = as.Date(file.info(paste0("~/iCloud/website/data/wdi/", dataset, ".RData"))$mtime)) %>%
  mutate(html = paste0("[html](https://fgeerolf.com/data/wdi/", dataset, '.html)')) %>%
  print_table_conditional()
dataset LAST_DOWNLOAD html
SP.POP.TOTL 2025-09-27 [html]
NY.GDP.MKTP.KD.ZG 2025-09-27 [html]
NY.GDP.MKTP.CD 2025-09-27 [html]

LAST_COMPILE

LAST_COMPILE
2025-10-10

Last

Code
SP.POP.TOTL %>%
  group_by(year) %>%
  summarise(Nobs = n()) %>%
  arrange(desc(year)) %>%
  head(1) %>%
  print_table_conditional()
year Nobs
2024 265

Nobs - Javascript

Code
SP.POP.TOTL %>%
  left_join(iso2c, by = "iso2c") %>%
  group_by(iso2c, Iso2c) %>%
  summarise(Nobs = n(),
            `Year 1` = first(year),
            `Pop 1` = first(value),
            `Year 2` = last(year),
            `Pop 2` = last(value)) %>%
  arrange(-Nobs) %>%
  mutate(Flag = gsub(" ", "-", str_to_lower(Iso2c)),
         Flag = paste0('<img src="../../bib/flags/vsmall/', Flag, '.png" alt="Flag">')) %>%
  select(Flag, everything()) %>%
  {if (is_html_output()) datatable(., filter = 'top', rownames = F, escape = F) else .}

China, E.U., U.S.

All

Code
SP.POP.TOTL %>%
  right_join(iso2c, by = "iso2c") %>%
  filter(iso2c %in% c("1W", "US", "CN", "EU")) %>%
  group_by(year) %>%
  mutate(value = value/value[iso2c == "1W"]) %>%
  year_to_date %>%
  filter(!(iso2c == "1W")) %>%
  mutate(Iso2c = ifelse(iso2c == "EU", "Europe", Iso2c)) %>%
  left_join(colors, by = c("Iso2c" = "country")) %>%
  mutate(color = ifelse(iso2c == "US", color2, color)) %>%
  ggplot(.) + theme_minimal() + scale_color_identity() +
  geom_line(aes(x = date, y = value, color = color)) +
  add_3flags +
  scale_x_date(breaks = seq(1950, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(0, 70, 2),
                     labels = scales::percent_format(accuracy = 1),
                     limits = 0.01*c(0, 25)) + 
  xlab("") + ylab("% de la population mondiale")

1980-

Code
SP.POP.TOTL %>%
  right_join(iso2c, by = "iso2c") %>%
  filter(iso2c %in% c("1W", "US", "CN", "EU")) %>%
  group_by(year) %>%
  mutate(value = value/value[iso2c == "1W"]) %>%
  year_to_date %>%
  filter(!(iso2c == "1W")) %>%
  mutate(Iso2c = ifelse(iso2c == "EU", "Europe", Iso2c)) %>%
  left_join(colors, by = c("Iso2c" = "country")) %>%
  mutate(color = ifelse(iso2c == "US", color2, color)) %>%
  filter(date >= as.Date("1980-01-01")) %>%
  ggplot(.) + theme_minimal() + scale_color_identity() +
  geom_line(aes(x = date, y = value, color = color)) +
  add_3flags +
  scale_x_date(breaks = seq(1950, 2025, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(0, 70, 2),
                     labels = scales::percent_format(accuracy = 1),
                     limits = 0.01*c(0, 25)) + 
  xlab("") + ylab("% de la population mondiale")

Germany, France, Italy

All

Code
SP.POP.TOTL %>%
  right_join(iso2c, by = "iso2c") %>%
  filter(iso2c %in% c("1W", "DE", "FR", "IT")) %>%
  group_by(year) %>%
  mutate(value = value/value[iso2c == "1W"]) %>%
  year_to_date %>%
  filter(!(iso2c == "1W")) %>%
  mutate(Iso2c = ifelse(iso2c == "EU", "Europe", Iso2c)) %>%
  left_join(colors, by = c("Iso2c" = "country")) %>%
  mutate(color = ifelse(iso2c == "US", color2, color)) %>%
  ggplot(.) + theme_minimal() + scale_color_identity() +
  geom_line(aes(x = date, y = value, color = color)) +
  add_3flags +
  scale_x_date(breaks = seq(1950, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(0, 70, 0.5),
                     labels = scales::percent_format(accuracy = .1),
                     limits = 0.01*c(0, 3)) + 
  xlab("") + ylab("% de la population mondiale")

1980-

Code
SP.POP.TOTL %>%
  right_join(iso2c, by = "iso2c") %>%
  filter(iso2c %in% c("1W", "DE", "FR", "IT")) %>%
  group_by(year) %>%
  mutate(value = value/value[iso2c == "1W"]) %>%
  year_to_date %>%
  filter(!(iso2c == "1W")) %>%
  mutate(Iso2c = ifelse(iso2c == "EU", "Europe", Iso2c)) %>%
  left_join(colors, by = c("Iso2c" = "country")) %>%
  mutate(color = ifelse(iso2c == "US", color2, color)) %>%
  filter(date >= as.Date("1980-01-01")) %>%
  ggplot(.) + theme_minimal() + scale_color_identity() +
  geom_line(aes(x = date, y = value, color = color)) +
  add_3flags +
  scale_x_date(breaks = seq(1950, 2100, 5) %>% paste0("-01-01") %>% as.Date,
               labels = date_format("%Y")) +
  scale_y_continuous(breaks = 0.01*seq(0, 70, 0.5),
                     labels = scales::percent_format(accuracy = .1),
                     limits = 0.01*c(0, 3)) + 
  xlab("") + ylab("% de la population mondiale")