---
title: "As child mortality falls, risk concentrates at birth"
subtitle: "Regional mortality rates declined sharply from 1990 to 2023, but neonatal deaths fell less than under-five deaths — shifting risk toward the earliest days of life. Each dumbbell shows the change from 1990 (open circle) to 2023 (filled) by region. Rates per 1,000 live births."
description: "Regional child mortality rates declined sharply from 1990 to 2023, but neonatal deaths fell more slowly than under-five deaths — shifting risk toward the earliest days of life. This dumbbell chart visualizes that divergence across four world regions using UNICEF Child Mortality Estimates 2024, built with ggplot2 and patchwork in R."
date: "2026-04-18"
author:
- name: "Steven Ponce"
url: "https://stevenponce.netlify.app"
citation:
url: "https://stevenponce.netlify.app/data_visualizations/30DayChartChallenge/2026/30dcc_2026_18.html"
categories: ["30DayChartChallenge", "2026"]
tags: [
"30DayChartChallenge",
"Relationships",
"UNICEF",
"Child Mortality",
"Neonatal Mortality",
"Dumbbell Chart",
"Public Health",
"Global Health",
"ggplot2",
"patchwork",
"R Programming",
"Data Journalism"
]
image: "thumbnails/30dcc_2026_18.png"
format:
html:
toc: true
toc-depth: 5
code-link: true
code-fold: true
code-tools: true
code-summary: "Show code"
editor_options:
chunk_output_type: inline
execute:
freeze: true
cache: true
error: false
message: false
warning: false
eval: true
---
{#fig-1}
### [**Steps to Create this Graphic**]{.mark}
#### [1. Load Packages & Setup]{.smallcaps}
```{r}
#| label: load
#| warning: false
#| message: false
#| results: "hide"
## 1. LOAD PACKAGES & SETUP ----
suppressPackageStartupMessages({
pacman::p_load(
tidyverse, ggtext, showtext, janitor,
scales, glue, camcorder, readxl, here, patchwork
)
})
### |- figure size ----
camcorder::gg_record(
dir = here::here("temp_plots"),
device = "png",
width = 10,
height = 7,
units = "in",
dpi = 320
)
# Source utility functions
suppressMessages(source(here::here("R/utils/fonts.R")))
source(here::here("R/utils/social_icons.R"))
source(here::here("R/utils/image_utils.R"))
source(here::here("R/themes/base_theme.R"))
```
#### [2. Read in the Data]{.smallcaps}
```{r}
#| label: read
#| include: true
#| eval: true
#| warning: false
path_u5mr <- here("data", "30DayChartChallenge", "2026", "Under-five_Mortality_Rates_2024.xlsx")
path_nmr <- here("data", "30DayChartChallenge", "2026", "Neonatal_Mortality_Rates_2024.xlsx")
# Helper: read one regional sheet from an IGME xlsx and return a long tibble
read_igme_sheet <- function(path, sheet, indicator_label, skip = 15) {
read_excel(path, sheet = sheet, skip = skip) |>
clean_names() |>
filter(uncertainty_bounds == "Median") |>
select(region_name, starts_with("x")) |>
pivot_longer(
cols = starts_with("x"),
names_to = "year_raw",
values_to = "rate"
) |>
mutate(
year = as.integer(str_extract(year_raw, "\\d{4}")),
rate = as.numeric(rate),
indicator = indicator_label
) |>
filter(!is.na(rate), year >= 1990, year <= 2023) |>
select(region_name, year, rate, indicator) |>
distinct(region_name, year, indicator, .keep_all = TRUE)
}
df_u5mr <- read_igme_sheet(path_u5mr, "U5MR Regional estimates", "Under-Five (U5MR)")
df_nmr <- read_igme_sheet(path_nmr, "NMR Regional estimates", "Neonatal (NMR)")
df_all <- bind_rows(df_u5mr, df_nmr)
```
#### [3. Examine the Data]{.smallcaps}
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
glimpse(df_all)
df_all |> distinct(region_name) |> arrange(region_name) |> print(n = 30)
df_all |> filter(year %in% c(1990, 2023)) |> arrange(indicator, region_name, year)
```
#### [4. Tidy Data]{.smallcaps}
```{r}
#| label: tidy
#| warning: false
# Regions to include — one global anchor + four regional contrasts
regions_keep <- c(
"World",
"Sub-Saharan Africa",
"South Asia",
"Latin America and the Caribbean",
"East Asia and the Pacific"
)
# Dumbbell endpoints: 1990 and 2023
df_dumbbell <- df_all |>
filter(
region_name %in% regions_keep,
year %in% c(1990, 2023)
) |>
mutate(
year_label = if_else(year == 1990, "y1990", "y2023"),
# Short region names for axis labels
region_short = case_when(
region_name == "World" ~ "World",
region_name == "Sub-Saharan Africa" ~ "Sub-Saharan\nAfrica",
region_name == "South Asia" ~ "South Asia",
str_detect(region_name, "Latin America") ~ "Latin America\n& Caribbean",
str_detect(region_name, "East Asia") ~ "East Asia\n& Pacific",
TRUE ~ region_name
)
) |>
pivot_wider(
id_cols = c(region_name, region_short, indicator),
names_from = year_label,
values_from = rate
) |>
mutate(
decline_abs = y1990 - y2023,
decline_pct = (y1990 - y2023) / y1990
)
# Sort order
region_order <- df_dumbbell |>
filter(indicator == "Under-Five (U5MR)") |>
arrange(y2023) |>
pull(region_short)
df_dumbbell <- df_dumbbell |>
mutate(region_short = factor(region_short, levels = region_order))
# Neonatal share annotation
nmr_world_2023 <- df_dumbbell |>
filter(indicator == "Neonatal (NMR)", region_name == "World") |>
pull(y2023)
u5mr_world_2023 <- df_dumbbell |>
filter(indicator == "Under-Five (U5MR)", region_name == "World") |>
pull(y2023)
nmr_share_2023 <- round(nmr_world_2023 / u5mr_world_2023 * 100)
nmr_world_1990 <- df_dumbbell |>
filter(indicator == "Neonatal (NMR)", region_name == "World") |>
pull(y1990)
u5mr_world_1990 <- df_dumbbell |>
filter(indicator == "Under-Five (U5MR)", region_name == "World") |>
pull(y1990)
nmr_share_1990 <- round(nmr_world_1990 / u5mr_world_1990 * 100)
```
#### [5. Visualization Parameters]{.smallcaps}
```{r}
#| label: params
#| include: true
#| warning: false
### |- plot aesthetics ----
colors <- get_theme_colors(palette = list(
"u5mr" = "#4a90b8",
"nmr" = "#1a3a5c",
"segment" = "#d0dde6",
"dot_1990"= "#7a9bb5",
"text" = "#1e2d3d",
"subtle" = "#7a8a99"
))
col_u5mr <- colors$palette$u5mr
col_nmr <- colors$palette$nmr
col_segment <- colors$palette$segment
col_dot_1990 <- colors$palette$dot_1990
col_text <- colors$palette$text
col_subtle <- colors$palette$subtle
### |- titles and caption ----
title_text <- "As child mortality falls, risk concentrates at birth"
subtitle_text <- paste0(
"Regional mortality rates declined sharply from 1990 to 2023, but neonatal deaths fell ",
"less than under-five deaths — shifting risk toward the earliest days of life.<br>",
"Each dumbbell shows the change from ",
"<span style='color:", col_dot_1990, "; font-weight:600'>1990 (open circle)</span>",
" to ",
"<span style='color:", col_nmr, "; font-weight:600'>2023 (filled)</span>",
" by region. Rates per 1,000 live births."
)
caption_text <- create_dcc_caption(
dcc_year = 2026,
dcc_day = 18,
source_text = "UN IGME via UNICEF · Child Mortality Estimates 2024 (data.unicef.org)"
)
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
### |- base and weekly theme ----
base_theme <- create_base_theme(colors)
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
axis.ticks = element_blank(),
axis.line = element_blank(),
panel.grid.major.x = element_line(color = "gray93", linewidth = 0.3),
panel.grid.major.y = element_blank(),
panel.grid.minor = element_blank(),
plot.title = element_text(
family = fonts$title, face = "bold", size = 20,
color = col_text, margin = margin(b = 6)
),
plot.subtitle = element_markdown(
family = 'sans', size = 10, color = "#4a5568",
margin = margin(b = 16), lineheight = 1.4
),
plot.caption = element_markdown(
family = fonts$text, size = 7.5, color = col_subtle,
margin = margin(t = 12), hjust = 0
),
legend.position = "none",
plot.margin = margin(16, 16, 10, 16)
)
)
theme_set(weekly_theme)
```
#### [6. Plot]{.smallcaps}
```{r}
#| label: plot
#| warning: false
### |- dumbbell builder function ----
build_dumbbell_panel <- function(data, indicator_name, col_2023, panel_title, panel_subtitle) {
d <- data |> filter(indicator == indicator_name)
ggplot(d, aes(y = region_short)) +
# Connector segment (1990 → 2023)
geom_segment(
aes(x = y2023, xend = y1990, yend = region_short),
color = col_segment,
linewidth = 1.8,
lineend = "round"
) +
# 1990 endpoint (muted)
geom_point(
aes(x = y1990),
color = col_dot_1990,
size = 3.5,
shape = 21,
fill = "white",
stroke = 1.2
) +
# 2023 endpoint (accent)
geom_point(
aes(x = y2023),
color = col_2023,
size = 4.5,
shape = 21,
fill = col_2023,
stroke = 0
) +
# 2023 rate label (right of dot)
geom_text(
aes(x = y2023, label = round(y2023, 1)),
hjust = -0.5,
size = 2.8,
color = col_text,
family = fonts$text
) +
labs(
title = panel_title,
subtitle = panel_subtitle,
x = NULL, y = NULL
) +
theme(
plot.title = element_text(
family = fonts$title, face = "bold", size = 11,
color = col_2023, margin = margin(b = 2)
),
plot.subtitle = element_markdown(
family = 'sans', size = 8.5, color = col_subtle,
margin = margin(b = 10), lineheight = 1.3
),
axis.text.y = element_text(
family = fonts$text, size = 8.5, color = col_text,
lineheight = 1.2
),
axis.text.x = element_text(
family = fonts$text, size = 7.5, color = col_subtle
),
panel.grid.major.x = element_line(color = "gray93", linewidth = 0.3),
panel.grid.major.y = element_blank(),
panel.grid.minor = element_blank(),
plot.margin = margin(8, 24, 8, 8)
)
}
### |- individual plots ----
p_u5mr <- build_dumbbell_panel(
data = df_dumbbell,
indicator_name = "Under-Five (U5MR)",
col_2023 = col_u5mr,
panel_title = "Under-Five Mortality Rate",
panel_subtitle = "Deaths per 1,000 live births, children under age 5"
)
p_nmr <- build_dumbbell_panel(
data = df_dumbbell,
indicator_name = "Neonatal (NMR)",
col_2023 = col_nmr,
panel_title = "Neonatal Mortality Rate",
panel_subtitle = "Deaths per 1,000 live births, first 28 days of life"
) +
annotate(
"text",
x = Inf, y = -Inf,
label = glue::glue(
"Globally, neonatal deaths rose from {nmr_share_1990}% to {nmr_share_2023}%\n",
"of all under-five deaths (1990 to 2023)"
),
hjust = 1.05, vjust = -0.6,
size = 3.0, color = col_nmr,
family = fonts$text,
lineheight = 1.3,
fontface = "italic"
)
### |- combined plots ----
p <- (p_u5mr | p_nmr) +
plot_annotation(
title = title_text,
subtitle = subtitle_text,
caption = caption_text,
theme = theme(
plot.title = element_text(
family = fonts$title, face = "bold", size = 26,
color = col_text, margin = margin(b = 6)
),
plot.subtitle = element_markdown(
family = 'sans', size = 8, color = "#4a5568",
margin = margin(b = 4), lineheight = 1.4
),
plot.caption = element_markdown(
family = fonts$text, size = 6.5, color = col_subtle,
margin = margin(t = 10), hjust = 0
),
plot.margin = margin(16, 16, 10, 16)
)
)
```
#### [7. Save]{.smallcaps}
```{r}
#| label: save
#| warning: false
### |- plot image ----
save_plot_patchwork(
p,
type = "30daychartchallenge",
year = 2026,
day = 18,
width = 10,
height = 7
)
```
#### [8. Session Info]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for Session Info
```{r, echo = FALSE}
#| eval: true
#| warning: false
sessionInfo()
```
:::
#### [9. GitHub Repository]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for GitHub Repo
The complete code for this analysis is available in [`30dcc_2026_18.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2026/30dcc_2026_18.qmd).
For the full repository, [click here](https://github.com/poncest/personal-website/).
:::
#### [10. References]{.smallcaps}
::: {.callout-tip collapse="true"}
##### Expand for References
1. **Data Sources:**
- UN Inter-agency Group for Child Mortality Estimation (UN IGME) via UNICEF.
*Child Mortality Estimates 2024* [Dataset].
https://data.unicef.org/resources/dataset/child-mortality/
- Under-five_Mortality_Rates_2024.xlsx — sheet: "U5MR Regional estimates"
- Neonatal_Mortality_Rates_2024.xlsx — sheet: "NMR Regional estimates"
Last updated: March 2025 | License: CC BY 3.0 IGO
:::
#### [11. Custom Functions Documentation]{.smallcaps}
::: {.callout-note collapse="true"}
##### 📦 Custom Helper Functions
This analysis uses custom functions from my personal module library for efficiency and consistency across projects.
**Functions Used:**
- **`fonts.R`**: `setup_fonts()`, `get_font_families()` - Font management with showtext
- **`social_icons.R`**: `create_social_caption()` - Generates formatted social media captions
- **`image_utils.R`**: `save_plot()` - Consistent plot saving with naming conventions
- **`base_theme.R`**: `create_base_theme()`, `extend_weekly_theme()`, `get_theme_colors()` - Custom ggplot2 themes
**Why custom functions?**\
These utilities standardize theming, fonts, and output across all my data visualizations. The core analysis (data tidying and visualization logic) uses only standard tidyverse packages.
**Source Code:**\
View all custom functions → [GitHub: R/utils](https://github.com/poncest/personal-website/tree/master/R)
:::