Skip to content

Instantly share code, notes, and snippets.

@chasemc
Created August 13, 2020 14:12
Show Gist options
  • Save chasemc/d3a40fcb2afd64a7fba1affaa65f1fb9 to your computer and use it in GitHub Desktop.
Save chasemc/d3a40fcb2afd64a7fba1affaa65f1fb9 to your computer and use it in GitHub Desktop.
library(ggplot2)
library(data.table)
library(geofacet)
library(magrittr)
raw_data <- data.table::fread("http://covidtracking.com/api/states/daily.csv")
raw_data$date <- as.Date(as.character(raw_data$date), "%Y%m%d")
raw_data <- raw_data[date > "2020-03-15", ]
plot(raw_data[ , sum(hospitalizedCurrently), date], ylim=c(0,8e4))
abline(v=as.Date("2020-07-15"), col="red")
lines(raw_data[ , sum(positiveIncrease), date])
raw_data[ , list(hosp=sum(hospitalizedCurrently),
cases=sum(positiveIncrease)), date] %>%
ggplot() +
geom_line(aes(x = date, y=cases)) +
geom_smooth(aes(x = date, y=cases), method = "gam") +
geom_point(aes(x=date, y=hosp)) +
geom_vline(xintercept = as.Date("2020-07-15"), col="red")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment