---
title: "Cheap coffee isn't necessarily affordable coffee"
subtitle: "The Cappuccino Index measures the minutes a barista must work to afford a small cappuccino. Across these countries, barista wages vary far more than cappuccino prices."
description: "An annotated scatter plot comparing mean hourly barista wages to mean cappuccino prices across 87 countries, using the Cappuccino Index (minutes of work per cappuccino) with iso-affordability contour lines at 30/60/120 minutes. Pakistan and India show cheap coffee but extreme work-time costs due to low wages, while Switzerland and Denmark show expensive coffee but low work-time costs due to high wages. Built in R with ggplot2, geomtextpath, and ggrepel."
date: "2026-09-07"
author:
- name: "Steven Ponce"
url: "https://stevenponce.netlify.app"
citation:
url: "https://stevenponce.netlify.app/data_visualizations/TidyTuesday/2026/tt_2026_36.html"
categories: ["TidyTuesday", "2026"]
tags: [
"TidyTuesday",
"Scatter Plot",
"Coffee",
"Economics",
"Affordability",
"Wages",
"Cross-Country Comparison",
"R",
"ggplot2",
"geomtextpath",
"ggrepel",
"Log Scale",
"Annotation",
"2026"
]
image: "thumbnails/tt_2026_36.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({
if (!require("pacman")) install.packages("pacman")
pacman::p_load(
tidyverse, ggtext, showtext, janitor, ggrepel,
scales, glue, skimr, ggview, geomtextpath
)
})
# 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
## 2. READ IN THE DATA ----
tt <- tidytuesdayR::tt_load(2026, week = 36)
cafe <- tt$cafe
cappuccino_index <- tt$cappuccino_index
rm(tt)
```
#### [3. Examine the Data]{.smallcaps}
```{r}
#| label: examine
#| include: true
#| eval: true
#| results: 'hide'
#| warning: false
## 3. EXAMINING THE DATA ----
glimpse(cafe)
skim_without_charts(cafe)
glimpse(cappuccino_index)
skim_without_charts(cappuccino_index)
```
#### [4. Tidy Data]{.smallcaps}
```{r}
#| label: tidy
#| warning: false
# Country-level means —
driver_diag <- cafe |>
group_by(country) |>
summarise(
n = n(),
mean_price = mean(price_gbp),
mean_wage = mean(hourly_wage_gbp),
.groups = "drop"
) |>
left_join(
cappuccino_index |> select(country, published_index = index),
by = "country"
)
# Primary contrast -
primary_countries <- c("India", "Pakistan", "Switzerland", "Denmark")
# Winning contour set from cheap-render testing: 30 / 60 / 120 -
iso_lines <- tibble(
index_level = c(30, 60, 120),
intercept = log(index_level / 60),
contour_label = paste0(index_level, " min")
)
```
#### [5. Visualization Parameters]{.smallcaps}
```{r}
#| label: params
#| include: true
#| warning: false
### |- plot aesthetics ----
colors <- get_theme_colors(
palette = c(highlight = "#722F37", secondary = "gray70")
)
### |- titles and caption ----
title_text <- str_glue("Cheap coffee isn't necessarily affordable coffee")
subtitle_line1 <- "The **Cappuccino Index** measures the minutes a barista must work to afford a small cappuccino." |>
str_wrap(width = 100) |>
str_replace_all("\n", "<br>")
subtitle_line2 <- "Across these countries, barista wages vary far more than cappuccino prices." |>
str_wrap(width = 90) |>
str_replace_all("\n", "<br>")
subtitle_text <- str_glue("{subtitle_line1}<br>{subtitle_line2}")
caption_source <- "James Hoffmann via Filip Reierson. Index = 60 x mean price / mean wage per country. Cross-country dispersion (log scale): barista wages vary 2.5x more than cappuccino prices." |>
str_wrap(width = 100) |>
str_replace_all("\n", "<br>")
caption_text <- create_social_caption(
tt_year = 2026,
tt_week = 36,
source_text = caption_source
)
### |- fonts ----
setup_fonts()
fonts <- get_font_families()
### |- plot theme ----
base_theme <- create_base_theme(colors)
weekly_theme <- extend_weekly_theme(
base_theme,
theme(
plot.title = element_textbox_simple(
size = 20,
face = "bold",
family = fonts$title_1,
color = colors$title,
lineheight = 1.1,
margin = margin(b = 8)
),
plot.subtitle = element_textbox_simple(
size = 12.5,
family = fonts$subtitle,
color = colors$subtitle,
margin = margin(b = 20)
),
plot.caption = element_textbox_simple(
size = 6.0,
family = fonts$caption,
color = colors$caption,
margin = margin(t = 12)
),
panel.grid.minor = element_blank(),
panel.grid.major = element_line(color = "gray92", linewidth = 0.25)
)
)
theme_set(weekly_theme)
```
#### [6. Plot]{.smallcaps}
```{r}
#| label: plot
#| warning: false
### |- plot ----
p <- driver_diag |>
ggplot(aes(x = mean_wage, y = mean_price)) +
geom_textabline(
data = iso_lines,
aes(slope = 1, intercept = intercept, label = contour_label),
color = "gray55", linetype = "dashed", linewidth = 0.35,
size = 2.8, hjust = 0.88, text_smoothing = 0
) +
geom_point(alpha = 0.45, color = "gray55", size = 1.8) +
geom_point(
data = driver_diag |> filter(country %in% primary_countries),
color = "#722F37", size = 3
) +
geom_text_repel(
data = driver_diag |> filter(country %in% primary_countries),
aes(label = country),
size = 3.4, fontface = "plain", color = "#2C2825",
min.segment.length = 0, seed = 1234,
box.padding = 0.5, point.padding = 0.3, force = 2, max.overlaps = Inf
) +
annotate(
"richtext",
x = 0.6, y = 1.5,
label = "**Cheap, but not affordable**<br>India \u00b7 £1.96 \u2192 172 min<br>Pakistan \u00b7 £1.87 \u2192 277 min",
hjust = 0, size = 3.1, color = "#2C2825",
fill = NA, label.color = NA
) +
annotate(
"richtext",
x = 7, y = 4.3,
label = "**Expensive, but relatively affordable**<br>Switzerland \u00b7 £5.41 \u2192 14 min<br>Denmark \u00b7 £5.41 \u2192 19 min",
hjust = 0, size = 3.1, color = "#2C2825",
fill = NA, label.color = NA
) +
scale_x_log10(labels = scales::label_currency(prefix = "£")) +
scale_y_log10(labels = scales::label_currency(prefix = "£")) +
labs(
title = title_text,
subtitle = subtitle_text,
caption = caption_text,
x = "Mean hourly wage (log scale)",
y = "Mean cappuccino price (log scale)"
)
```
### [7. Save]{.smallcaps}
```{r}
#| label: save
#| warning: false
### |- save ----
main_path <- here::here("data_visualizations", "TidyTuesday", "2026", "tt_2026_36.png")
thumb_path <- here::here("data_visualizations", "TidyTuesday", "2026", "thumbnails", "tt_2026_36.png")
# Full-size version, for the QMD figure
save_ggplot(
plot = p,
file = main_path,
width = 10,
height = 7.5,
units = "in",
dpi = 300,
create.dir = TRUE
)
# Reduced-size thumbnail, for the YAML `image:` field
fs::dir_create(dirname(thumb_path))
magick::image_read(main_path) |>
magick::image_resize("400") |>
magick::image_write(thumb_path)
```
#### [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 [`tt_2026_36.qmd`](https://github.com/poncest/personal-website/blob/master/data_visualizations/TidyTuesday/2026/tt_2026_36.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 Source:**
- TidyTuesday 2026 Week 36: [The Cappuccino Index](https://github.com/rfordatascience/tidytuesday/blob/main/data/2026/2026-09-08/readme.md)
:::
#### [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)
:::