Skip to content

Instantly share code, notes, and snippets.

@jrosen48
Created July 2, 2020 21:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jrosen48/98b62cff09b2f498c435b47d658af3ce to your computer and use it in GitHub Desktop.
Save jrosen48/98b62cff09b2f498c435b47d658af3ce to your computer and use it in GitHub Desktop.
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