R Markdown

library(readr)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
library(forcats)
library(ggplot2)
library(treemapify)
## Warning: package 'treemapify' was built under R version 4.5.1
library(scales)
## 
## Attaching package: 'scales'
## The following object is masked from 'package:readr':
## 
##     col_factor
GBD1 <- read_csv("IHME-GBD_2021_DATA-ab0ee0c1-1.csv")
## Rows: 374 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (6): measure, location, sex, age, cause, metric
## dbl (4): year, val, upper, lower
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
gbd_core <- GBD1 %>%
  filter(
    measure == "Deaths",
    location == "Global",
    sex == "Both",
    age == "All ages",
    metric == "Rate"
  )

gbd_avg <- gbd_core %>%
  group_by(cause) %>%
  summarise(
    avg_val   = mean(val, na.rm = TRUE),
    avg_lower = mean(lower, na.rm = TRUE),
    avg_upper = mean(upper, na.rm = TRUE),
    n_years   = n(),                 
    .groups = "drop"
  ) %>%
  arrange(desc(avg_val)) %>%
  mutate(cause = fct_reorder(cause, avg_val))
library(treemapify)

p_treemap <- ggplot(gbd_avg, aes(area = avg_val, fill = avg_val,
                                 label = paste0(cause))) +
  geom_treemap() +
  geom_treemap_text(colour = "white", place = "centre", grow = TRUE) +
  scale_fill_gradient(low = "lightblue", high = "darkblue",
                      labels = label_number(accuracy = 0.1)) +
  labs(
    title = "Average Global Death Rate by Cause (2011-2021)",
    fill = "Avg rate per 100k"
  )

p_treemap

treemap_cancer

ggsave("treemap_cancer_rates.png", p_treemap, width = 20, height = 12, dpi = 1000)

The heatmap shows the average global cancer death rate per 100,000 people (2011–2021). Each rectangle represents a cancer type, sized by its average death rate and shaded from light to dark blue to indicate lower to higher values. Lung, trachea, and bronchus cancers stand out with the largest, darkest areas, reflecting their major contribution to global mortality.

This visualization highlights the relative scale of cancer burden across causes in a compact form. While averaging clarifies overall patterns, it also hides year-to-year changes and makes smaller cancers harder to compare.