knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Source code.

tl;dr

library(covid19)
library(dplyr)
library(lubridate)
library(ggplot2)

confirmed_cases <- read_confirmed_cases_jhu_csse()

Plots cumulative number of confirmed cases for a few selected countries. It is easy to tell by the shape of the curve whether the daily number of cases are increasing vs countries where the rate of new infections has decreased.

confirmed_cases %>%
  dplyr::filter(country_region %in% c("Czechia", "China", "Korea, South", "Iran", "Italy", "Spain", "US")) %>% 
  dplyr::group_by(country_region, date) %>% 
  dplyr::summarize(country_total = sum(cumulative_total)) %>% 
  ggplot(aes(x = date, y = country_total, group = country_region, color = country_region)) +
    geom_point(na.rm = TRUE) +
    geom_line(aes(y = country_total), na.rm = TRUE)  + 
  theme(
    panel.grid.minor = element_line(color="grey60", size=0.5),
    panel.grid.major = element_line(color="grey40", size=0.5),
    panel.background = element_rect(fill="snow2")
  ) +
  ggtitle("Confirmed cases for selected countries") +
  labs(x = "Date", y = "Cumulative Total", color = "Country")


jimtyhurst/covid19 documentation built on Aug. 30, 2020, 3:39 p.m.