Created
June 25, 2020 15:50
-
-
Save seandavi/1dab480e54cdd8452254489fd9df775b to your computer and use it in GitHub Desktop.
Countries vying for largest share of new COVID-19 cases
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(sars2pack) | |
library(dplyr) | |
library(zoo) | |
library(cowplot) | |
library(ggplot2) | |
y = ecdc_data() %>% dplyr::group_by(iso3c) %>% | |
add_incidence_column(count_column = 'confirmed') %>% | |
align_to_baseline(confirmed>50,group_vars = 'iso3c') %>% | |
dplyr::arrange(date) %>% | |
dplyr::mutate(inc = zoo::rollmean(inc, 7, na.pad=TRUE)) %>% | |
dplyr::filter(!is.na(inc) & date<Sys.Date()-2) | |
p1=ggplot(y[y$iso3c %in% c('USA','BRA','RUS','IND'),], aes(x=index, y=inc, color=iso3c)) + | |
geom_line() + ggtitle('Countries vying for largest share of new COVID-19 cases per day') + | |
theme_bw() + ylab('New Cases per Day') + xlab('Days since 50 cases') | |
p2=ggplot(y[y$iso3c %in% c('USA','BRA','RUS','IND'),], aes(x=index, y=inc/population_2019*100000, color=iso3c)) + | |
geom_line() + ggtitle('Countries vying for largest share of new COVID-19 cases per day',subtitle = 'Cases/100k population') + | |
theme_bw() + ylab('New Cases per Day per 100k Population') + xlab('Days since 50 cases') | |
cowplot::plot_grid(p1,p2,nrow=2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ecdc_data() %>% dplyr::group_by(iso3c) %>%
add_incidence_column(count_column = 'confirmed') %>%
align_to_baseline(confirmed>50,group_vars = 'iso3c') %>%
dplyr::arrange(date) %>%
dplyr::mutate(inc = zoo::rollmean(inc, 7, na.pad=TRUE)) %>%
dplyr::filter(!is.na(inc) & date<Sys.Date()-2)