Last active
October 29, 2021 16:35
-
-
Save msjgriffiths/7a8e795bf207d2f0dc7b9839b3e425a0 to your computer and use it in GitHub Desktop.
Excess Deaths
This file contains 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(patchwork) | |
# CDC Covid-19 Excess Deaths | |
# https://data.cdc.gov/NCHS/Excess-Deaths-Associated-with-COVID-19/xkkf-xrst/ | |
df <- read_csv("https://data.cdc.gov/resource/xkkf-xrst.csv") | |
df %>% | |
filter(Outcome == "All causes", Type == "Unweighted") -> | |
df | |
df %>% | |
filter(State == "Florida", `Week Ending Date` >= "2020-01-01") %>% | |
filter(`Week Ending Date` < Sys.Date()-14) %>% | |
ggplot(aes(`Week Ending Date`)) + | |
geom_point(aes(y = `Observed Number`), alpha = .5) + | |
geom_line(aes(y = `Average Expected Count`), color = "blue") + | |
theme_minimal() + | |
coord_cartesian(ylim = c(0, 10000)) + | |
scale_x_date(date_labels = "%b '%y", date_breaks = "1 month") + | |
theme(axis.text.x = element_text(angle = 45)) + | |
labs(x = "Week Ending", y = "Number of Deaths", title = "Florida", subtitle = "Actual Deaths vs Expected (blue)") -> | |
g1 | |
df %>% | |
filter(State == "New York", `Week Ending Date` >= "2020-01-01") %>% | |
filter(`Week Ending Date` < Sys.Date()-14) %>% | |
ggplot(aes(`Week Ending Date`)) + | |
geom_point(aes(y = `Observed Number`), alpha = .5) + | |
geom_line(aes(y = `Average Expected Count`), color = "blue") + | |
theme_minimal() + | |
coord_cartesian(ylim = c(0, 10000)) + | |
scale_x_date(date_labels = "%b '%y", date_breaks = "1 month") + | |
theme(axis.text.x = element_text(angle = 45)) + | |
labs(x = "Week Ending", y = "Number of Deaths", title = "New York", subtitle = "Actual Deaths vs Expected (blue)") -> | |
g2 | |
g1 + g2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment