A donut chart, with an inset pie chart on the main causes of DALYs, coloured by different categories, and different causes within each category distinguished by opacity. Labels show percentage contribution and the names of causes.
Our World in Data
Public Health
{donutsk}
Author
Aditya Dahiya
Published
August 1, 2024
The dataset from Our World in Data provides comprehensive information on Disability Adjusted Life Years (DALYs) for various health conditions, including communicable, maternal, neonatal, nutritional diseases, injuries, and non-communicable diseases (NCDs). The data is sourced from the IHME’s Global Burden of Disease (GBD) study, which offers a detailed assessment of global health trends, encompassing death and DALY counts and rates for 371 diseases and injuries. The dataset, which spans from 1990 to 2021, was last updated on May 20, 2024, with the next update expected in May 2028. Detailed data can be retrieved from the Global Burden of Disease’s results tool here.
How I made these graphics?
Getting the data
Code
# Data Import and Wrangling Toolslibrary(tidyverse) # All things tidylibrary(owidR) # Get data from Our World in R# Final plot toolslibrary(scales) # Nice Scales for ggplot2library(fontawesome) # Icons display in ggplot2library(ggtext) # Markdown text supportlibrary(showtext) # Display fonts in ggplot2library(colorspace) # To lighten and darken colourslibrary(patchwork) # Combining plotslibrary(donutsk) # Pie & Donut Charts with labels# search1 <- owidR::owid_search("burden of disease")df1 <-owid("burden-of-disease-by-cause")# popdf <- owid("population-with-un-projections")
Visualization Parameters
Code
# Font for titlesfont_add_google("Fondamento",family ="title_font") # Font for the captionfont_add_google("Saira Extra Condensed",family ="caption_font") # Font for plot textfont_add_google("PT Sans Narrow",family ="body_font") showtext_auto()# Colour Paletteset.seed(41)mypal <- paletteer::paletteer_d("khroma::smoothrainbow")mypal <-sample(mypal, 25, replace = F)# Background Colourbg_col <-"white"text_col <-"grey20"text_hil <-"grey30"# Base Text Sizebts <-80plot_title <-"Causes of DALYs Worldwide"plot_subtitle <-str_wrap("A Donut Chart on the causes of death, disease and disability globally in 2021 (measured by DALYs).", 60)str_view(plot_subtitle)# 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>")plot_caption <-paste0("**Data:** IHME - Global Burden of Disease (GBD) Study | ","**Code:** ", social_caption_1, " | **Graphics:** ", social_caption_2 )rm(github, github_username, xtwitter, xtwitter_username, social_caption_1, social_caption_2)
Data Wrangling
Code
df2 <- df1 |>as_tibble() |>pivot_longer(cols =-c(year, entity, code),names_to ="indicator",values_to ="value" ) |>mutate(indicator =str_remove( indicator,"Total number of DALYs from " ),indicator =str_remove( indicator,"\n" ) ) |>mutate(indicator =str_to_title( indicator ),indicator =str_replace( indicator,"Hiv/Aids","HIV / AIDS" ),indicator =str_replace_all( indicator,"And","and" ) )plotdf <- df2 |>filter(year ==2021& entity =="World") |>mutate(indicator =fct(indicator),indicator_group =fct_collapse( indicator,"Lifestyle Disorders"=c("Cardiovascular Diseases", "Diabetes and Kidney Diseases", "Digestive Diseases", "Neoplasms", "Chronic Respiratory Diseases"),"Infectious Diseases"=c("Other Infectious Diseases", "Neglected Tropical Diseases and Malaria", "Enteric Infections", "HIV / AIDS and Sexually Transmitted Infections", "Respiratory Infections and Tuberculosis"),"Violence and Injuries"=c("Transport Injuries", "Self-Harm", "Interpersonal Violence","Unintentional Injuries", "Conflict and Terrorism", "Exposure To Forces Of Nature"),"Mental Health Disorders"=c("Neurological Disorders","Mental Disorders", "Substance Use Disorders"),"Others"=c("Musculoskeletal Disorders", "Maternal Disorders", "Nutritional Deficiencies", "Neonatal Disorders", "Skin and Subcutaneous Diseases", "Other Non-Communicable Diseases") )) |>select(entity, year, indicator_group, indicator, value) |> donutsk::packing(value = value, level = indicator_group) |>mutate(perc_outer =100* value /sum(value)) |>group_by(indicator_group) |>mutate(perc_inner =sum(perc_outer)) |>ungroup()labelsdf <- plotdf |>distinct(indicator_group, perc_inner) |>mutate(ymax =cumsum(perc_inner),ymin = ymax - perc_inner,x_var =case_when( indicator_group =="Violence and Injuries"~1.4, indicator_group =="Mental Health Disorders"~1.4,.default =1.3 ) ) |>select(-perc_inner) |>pivot_longer(cols =c(ymax, ymin),values_to ="y_var",names_to =NULL ) |>mutate(y_var = y_var /100 )