Skip to content

Instantly share code, notes, and snippets.

@topepo
Created March 30, 2020 02:23
Show Gist options
  • Save topepo/086435edd0538f31c3da7d48eebe6dbf to your computer and use it in GitHub Desktop.
Save topepo/086435edd0538f31c3da7d48eebe6dbf to your computer and use it in GitHub Desktop.
library(tidyverse)
library(lubridate)
theme_set(theme_bw())
dat <-
read_csv("https://raw.githubusercontent.com/nytimes/covid-19-data/master/us-counties.csv")
dat %>%
group_by(state) %>%
summarize(total_deaths = max(deaths)) %>%
arrange(desc(total_deaths))
sum(.Last.value$total_deaths)
# Latest data from:
max(dat$date)
dat <-
dat %>%
filter(state %in% c("South Carolina", "Connecticut")) %>%
mutate(county = factor(county))
dat %>%
filter(state == "Connecticut") %>%
ggplot(aes(x = date, y = cases, group = county, col = county)) +
geom_line() +
geom_point() +
facet_wrap(~ state) +
scale_y_log10() +
scale_color_brewer(palette = "Set1")
dat %>%
filter(state == "Connecticut") %>%
ggplot(aes(x = date, y = deaths, group = county, col = county)) +
geom_line() +
geom_point() +
scale_color_brewer(palette = "Set1")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment