World Bank data shows a relation between Wealth and Health - correlated, is it causative?
World Bank Data
A4 Size Viz
Governance
Author
Aditya Dahiya
Published
May 16, 2024
GDP per capita vs. Life Expectancy
I utilized data from the World Bank’s DataBank, a comprehensive analysis and visualization tool that houses a diverse collection of time series data spanning various topics. Specifically, I extracted information on Gross Domestic Product (GDP) and life expectancy for multiple countries over several years. Using this data, I created a scatter plot to explore the relationship between a country’s GDP and its life expectancy. The scatter plot allows for a visual examination of potential correlations or patterns between these two variables across different nations and over time. DataBank enables users to customize queries, generate tables, charts, and maps effortlessly, making it a valuable resource for data analysis and visualization. This tool facilitates not only the exploration of data but also the sharing and embedding of findings, encouraging collaboration and further analysis.
How I made this graphic?
Loading required libraries, data import & creating custom functions
Code
# Data Import and Wrangling Toolslibrary(tidyverse) # All things tidy# Final plot toolslibrary(scales) # Nice Scales for ggplot2library(fontawesome) # Icons display in ggplot2library(ggtext) # Markdown text support for ggplot2library(showtext) # Display fonts in ggplot2library(colorspace) # Lighten and Darken colourslibrary(patchwork) # Combining plots# Extras and Annotationslibrary(magick) # Image processing# Credits: Geospatial Science and Human Security at ORNL# Credits: @jpiburn, @petrbouchal, @bapfeld# install.packages("wbstats")library(wbstats)# indicators <- wbstats::wb_indicators()# indicators |> # filter(str_detect(indicator_desc, "Life expectancy")) |> # View()# # indicators |> # filter(str_detect(indicator_desc, "GDP per capita")) |> View()# indicators |> # filter(str_detect(indicator_id, "SP.POP.TOTL"))selected_indicators <-c("NY.GDP.PCAP.CD","SP.POP.TOTL","SP.DYN.LE00.IN")rawdf <-wb_data(indicator = selected_indicators,start_date =1980,end_date =2023 ) |> janitor::clean_names()
# Font for titlesfont_add_google("Poiret One",family ="title_font") font_add_google("Amita",family ="title2_font" )# Font for the captionfont_add_google("Barlow Condensed",family ="caption_font") # Font for plot textfont_add_google("Monda",family ="body_font") ts <-50showtext_auto()# Colour Palettesmypal <-c("darkred", "blue")bg_col <-"white"# Background Colourtext_col <-"grey10"# Colour for texttext_hil <-"grey30"# Colour for highlighted text# Caption stuff for the plotsysfonts::font_add(family ="Font Awesome 6 Brands",regular = here::here("docs", "Font Awesome 6 Brands-Regular-400.otf"))github <-""github_username <-"aditya-dahiya"xtwitter <-""xtwitter_username <-"@adityadahiyaias"social_caption_1 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{github};</span> <span style='color: {text_hil}'>{github_username} </span>")social_caption_2 <- glue::glue("<span style='font-family:\"Font Awesome 6 Brands\";'>{xtwitter};</span> <span style='color: {text_hil}'>{xtwitter_username}</span>")
Annotation Text for the Plot
Code
plot_title <-"Wealth & Wellness"plot_caption <-paste0("Data: World Bank. Databank.", " | **Code:** ", social_caption_1, " | **Graphics:** ", social_caption_2 )plot_subtitle <- glue::glue("Tracking Prosperity and Well-being:<br>A Comparative Analysis of GDP per<br>Capita and\nLife Expectancy<br>Trends in <b style='color:{mypal[2]}'>India</b> and <b style='color:{mypal[1]}'>China</b><BR>(1980-2020).<br>Each year, Size of the flag<br>represents total<br>population.")inset_text <-str_wrap("About the Data: DataBank, provided by the World Bank, offers a rich collection of time series data on various topics, allowing users to create customized queries, generate tables, charts, and maps effortlessly. One such dataset focuses on GDP per capita (in current US dollars) and life expectancy at birth for countries around the world. The GDP per capita data is sourced from the World Bank national accounts data and OECD National Accounts data files. It represents the gross domestic product divided by the midyear population, indicating the economic productivity per person. On the other hand, life expectancy at birth data is sourced from the United Nations Population Division, and other reliable sources like census reports and statistical publications from national statistical offices. Life expectancy at birth reflects the number of years a newborn infant would live if prevailing mortality patterns were to stay constant throughout its life. It is calculated as a weighted average, offering a snapshot of a population's mortality pattern at a given time. It is important to note that while life expectancy at birth provides an overall understanding of a population's mortality level, it doesn't reflect the individual mortality pattern one might experience throughout their life. This dataset provides invaluable insights into the economic and health trends of various countries over time. Using this data, one can draw meaningful comparisons and analyze the relationship between economic prosperity, as measured by GDP per capita, and the health of a nation, as measured by life expectancy at birth.", 50, whitespace_only =FALSE)