Last active
December 31, 2024 19:21
-
-
Save USMortality/ac9908501acffd8a2bd659794e754e5c to your computer and use it in GitHub Desktop.
Population used in OWID/CDC COVID-19 weekly death rates dataset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(tidyverse) | |
library(scales) | |
sf <- 2 | |
width <- 600 * sf | |
height <- 335 * sf | |
options(vsc.dev.args = list(width = width, height = height, res = 72 * sf)) | |
df <- read_csv("/Users/ben/Downloads/a.csv") | |
a <- df |> | |
filter(outcome == "death", age_group == "all_ages", vaccination_status == "vaccinated") |> | |
select(mmwr_week, unvaccinated_population, vaccinated_population) |> | |
pivot_longer( | |
cols = c(unvaccinated_population, vaccinated_population), | |
names_to = "vaccination_status", | |
values_to = "population" | |
) |> | |
mutate(vaccination_status = str_remove(vaccination_status, "_population")) | |
# Stacked Area Plot | |
a |> ggplot(aes(x = mmwr_week, y = population, fill = vaccination_status)) + | |
geom_area(alpha = 0.7) + | |
geom_hline(yintercept = 333e6, linetype = "dashed", color = "red", size = 1) + | |
scale_y_continuous( | |
labels = scales::label_number(scale_cut = scales::cut_si("M")) | |
) + | |
labs( | |
x = "MMWR Week", | |
y = "Population (in millions)", | |
fill = "Vaccination Status", | |
title = "Population used in OWID/CDC COVID-19 weekly death rates dataset", | |
subtitle = "Including reference line at 333M" | |
) + | |
theme_minimal() + | |
theme( | |
legend.position = "bottom", | |
plot.title = element_text(size = 16, face = "bold"), | |
plot.subtitle = element_text(size = 12) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment