Skip to content

Instantly share code, notes, and snippets.

@RandomCriticalAnalysis
Created April 2, 2020 22:29
Show Gist options
  • Save RandomCriticalAnalysis/b212f60fdd0f47e963f10b2bf5947e1a to your computer and use it in GitHub Desktop.
Save RandomCriticalAnalysis/b212f60fdd0f47e963f10b2bf5947e1a to your computer and use it in GitHub Desktop.
stated %>%
filter(
!is.na(region),
date >= as.Date("2020-03-01"),
state %in% c('NY','NJ','CT','MA','PA')
) %>%
mutate(
date_from=as.integer(date - as.Date("2020-03-01")),
value=death/pop*10^6
) %>%
filter(
!is.na(value),
value > 0
) %>% {
df= mutate(.,state=reorder(state_name,-value,min,na.rm=T))
altdf = df %>%
mutate(
state2=state
) %>%
select(-region,-division,-state)
#ggplot(df,aes(date_from,(death/pop*10^6) )) +
ggplot(df,aes(date,value )) +
facet_wrap(~state,ncol=10) +
scale_x_date(date_labels = "%b %d") +
geom_line(aes(group=state2),color='gray',data=altdf,size=.2) +
geom_line(color='red',size=1) +
theme_light() +
theme(
legend.position='none',
axis.text.x = element_text(angle = 45, hjust = 1)
) +
scale_y_log10() +
labs(
x=NULL,
caption='source: Covid tracking project'
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment