How have the average cost of a healthy diet and the share of the population unable to afford a healthy diet changed across countries from 2017 to 2025?
I used the World Bank Food Prices for Nutrition dataset to examine changes in the cost and affordability of a healthy diet between 2017 and 2025.
# Loaded tidyverse package for data transformation and visualization
library(tidyverse)
healthy_diet <- readr::read_csv("healthy_diet.csv")
# Rename the columns so they are easier to use
names(healthy_diet) <- c("classification_name", "classification_code", "country", "country_code", "year", "time_code", "cost", "cannot_afford")
# Preview data
head(healthy_diet)
## # A tibble: 6 × 8
## classification_name classification_code country country_code year time_code
## <chr> <chr> <chr> <chr> <dbl> <chr>
## 1 Food Prices for Nutr… FPN 5.0 Albania ALB 2017 YR2017
## 2 Food Prices for Nutr… FPN 5.0 Albania ALB 2018 YR2018
## 3 Food Prices for Nutr… FPN 5.0 Albania ALB 2019 YR2019
## 4 Food Prices for Nutr… FPN 5.0 Albania ALB 2020 YR2020
## 5 Food Prices for Nutr… FPN 5.0 Albania ALB 2021 YR2021
## 6 Food Prices for Nutr… FPN 5.0 Albania ALB 2022 YR2022
## # ℹ 2 more variables: cost <chr>, cannot_afford <chr>
The World Bank dataset contains missing observations. I converted the
cost and affordability variables to numeric values so that these missing
observations become NA.
# Convert the cost variable to numeric
healthy_diet$cost <- as.numeric(healthy_diet$cost)
# Convert the percent unable to afford a healthy diet to numeric
healthy_diet$cannot_afford <- as.numeric(healthy_diet$cannot_afford)
# Keep only rows with valid year, cost, and affordability data
healthy_diet_clean <- subset(healthy_diet, !is.na(year) & !is.na(cost) & !is.na(cannot_afford))
I used count() to determine how many observations were
available for each year after cleaning the dataset.
country_counts <- healthy_diet_clean %>% count(year)
country_counts
## # A tibble: 9 × 2
## year n
## <dbl> <int>
## 1 2017 159
## 2 2018 159
## 3 2019 159
## 4 2020 159
## 5 2021 159
## 6 2022 159
## 7 2023 159
## 8 2024 159
## 9 2025 159
The cleaned dataset contains 159 country observations for each year from 2017 through 2025. This provides a consistent number of observations for comparing annual averages.
I grouped the data by year and used summarize() to
calculate the average cost of a healthy diet and the average percentage
of the population unable to afford a healthy diet.
annual_summary <- healthy_diet_clean %>% group_by(year) %>% summarize(average_cost = mean(cost, na.rm = TRUE), average_cannot_afford = mean(cannot_afford, na.rm = TRUE))
annual_summary
## # A tibble: 9 × 3
## year average_cost average_cannot_afford
## <dbl> <dbl> <dbl>
## 1 2017 3.11 37.0
## 2 2018 3.16 35.4
## 3 2019 3.26 34.6
## 4 2020 3.40 36.2
## 5 2021 3.57 35.4
## 6 2022 4.01 35.0
## 7 2023 4.36 34.6
## 8 2024 4.49 33.7
## 9 2025 4.63 32.9
The average cost of a healthy diet increased from approximately 3.11 PPP dollars in 2017 to 4.63 PPP dollars in 2025. This represents an increase of approximately 49% over the period.
Although the increase occurred throughout the period, it became particularly noticeable after 2021. The average cost rose from approximately 3.57 PPP dollars in 2021 to more than 4.00 PPP dollars in 2022 and continued increasing through 2025.
Note on PPP dollars: The cost of a healthy diet is reported in Purchasing Power Parity (PPP) dollars per person per day. PPP adjusts for differences in price levels across countries, making costs more comparable internationally.
Despite the increase in the average cost of a healthy diet, the average share of the population unable to afford a healthy diet decreased from approximately 37.0% in 2017 to 32.9% in 2025.
This represents an improvement of approximately 4.1 percentage points. However, the trend was not consistent every year. The percentage increased from approximately 34.6% in 2019 to 36.2% in 2020 before declining again in later years.
The following graph shows how the average percentage of the population unable to afford a healthy diet changed between 2017 and 2025.
# Plotting average percent unable to afford a healthy diet by year
ggplot(data = annual_summary, aes(x = year, y = average_cannot_afford)) + geom_line() + geom_point() + labs(title = "Average Share Unable to Afford a Healthy Diet", x = "Year", y = "Percent Unable to Afford")
The analysis shows two different trends. The average cost of a healthy diet increased substantially between 2017 and 2025, while the average percentage of the population unable to afford a healthy diet declined. This suggests that although healthy diets became more expensive on average, affordability improved across the countries included in the analysis.