Created
July 2, 2020 21:44
-
-
Save jrosen48/98b62cff09b2f498c435b47d658af3ce to your computer and use it in GitHub Desktop.
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(readxl) | |
d <- read_excel("Downloads/Public-Dataset-Age.xlsx") | |
d %>% | |
mutate(month = lubridate::month(DATE, label = TRUE)) %>% | |
group_by(month, AGE_RANGE) %>% | |
summarize(total_cases = sum(NEW_ARCASES)) %>% | |
filter(AGE_RANGE != "Pending") %>% | |
mutate(total_cases_prop = total_cases / sum(total_cases)) %>% | |
ggplot(aes(y = total_cases_prop, x = AGE_RANGE, fill = as.factor(month))) + | |
geom_col(position = "dodge", alpha = 1) + | |
scale_fill_viridis_d("") + | |
coord_flip() + | |
theme_minimal() + | |
labs(x = "Age", y = "Proportion of Cases Per Month", | |
title = "COVID-19 Cases in Tennessee by Age Range", | |
subtitle = "Data: https://www.tn.gov/health/cedep/ncov/data/downloadable-datasets.html", | |
caption = "created by Joshua Rosenberg") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment