Created
May 22, 2020 21:13
-
-
Save shuckle16/cc958afe56a7073543e9af4365060195 to your computer and use it in GitHub Desktop.
plots county deaths / cases with moving averages
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(readr) | |
library(dplyr) | |
library(tidyquant) | |
library(ggplot2) | |
counties <- read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv") | |
counties %>% | |
filter(state == "Florida", county != "Unknown") %>% | |
group_by(county) %>% | |
arrange(county, date) %>% | |
mutate(new_deaths = c(NA, diff(deaths)), tot_deaths = sum(new_deaths, na.rm = T)) %>% | |
filter(tot_deaths > 25) %>% | |
ggplot(aes(x = date, y = new_deaths)) + | |
geom_point(alpha = .1) + | |
geom_line(aes(group = county), alpha = .1) + | |
geom_ma(ma_fun = SMA, n = 7, size = 1.5) + | |
facet_wrap(~county, scales = "free_y") | |
counties %>% | |
filter(state == "Florida", county != "Unknown") %>% | |
group_by(county) %>% | |
arrange(county, date) %>% | |
mutate(new_cases = c(NA, diff(cases)), tot_cases = sum(new_cases, na.rm = T)) %>% | |
filter(tot_cases > 250) %>% | |
ggplot(aes(x = date, y = new_cases)) + | |
geom_point(alpha = .1) + | |
geom_line(aes(group = county), alpha = .1) + | |
geom_ma(ma_fun = SMA, n = 7, size = 1.5) + | |
facet_wrap(~county, scales = "free_y") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment