Created
May 14, 2020 14:04
-
-
Save chasemc/6c46077244acbc61d7eded5ad94d3445 to your computer and use it in GitHub Desktop.
This file contains hidden or 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(ggplot2) | |
library(data.table) | |
library(geofacet) | |
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", ] | |
raw_data[ , corre := cor(totalTestResultsIncrease,positiveIncrease, | |
method = "spearman"), state] | |
raw_data[, maxHeight := max(totalTestResultsIncrease)*.75, state] | |
raw_data[, maxWidth := max(positiveIncrease)*.15, state] | |
ggplot(raw_data,aes(x = positiveIncrease, y=totalTestResultsIncrease)) + | |
geom_smooth(method="lm") + | |
geom_point(alpha = .2) + | |
geom_text( | |
aes(x=maxWidth,y=(maxHeight), label = round(corre,2))) + | |
facet_geo(~state, | |
grid = "us_state_grid1", | |
label = "name", | |
scales = "free") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment