USA COVID-19: Anniversary Of the First Death (Feb. 29, 2020)
Our World In Data
library(ggplot2)
library(scales)
library(forecast)
library(dplyr)
library(forecast)
library(readr)
theme_set(theme_gray())
- Load Covid-19 Data for USA
rm(list=ls())
US <- read_csv("./DATA/owid-covid-data.csv") %>% filter(location=="United States") %>%
select(date,new_cases,new_deaths,total_cases,total_deaths)
- Calculate 14 Day Moving Averages: Cases and Deaths
US$MAC <- ma(US$new_cases,14,centre = TRUE)
US$MAD <- ma(US$new_deaths,14,centre = TRUE)
summary(US)
- Plot of Daily Cases with 14 Day Moving Averages
US %>% filter(date >="2020-01-24") %>% ggplot() + geom_line(aes(x=date,y=new_cases,col="Daily Cases"),lwd=1) +
geom_line(aes(x=date,y=MAC,col="Moving Average"),lwd=1) +
labs(title="US Daily Cases w/ 14 Day Moving Average",x="Year",y="Daily Cases") +
scale_y_continuous(labels=comma)
Plot of Daily Cases
- Plot of Daily Deaths with 14 Day Moving Average
US %>% filter(date >="2020-02-29") %>% ggplot() + geom_line(aes(x=date,y=new_deaths,col="Daily Deaths"),lwd=1) +
geom_line(aes(x=date,y=MAD,col="Moving Average"),lwd=1) +
labs(title="US Daily Deaths w/ 14 Day Moving Average",x="Year",y="Daily Deaths") +
scale_y_continuous(labels=comma)
Plot of Daily Deaths
Video Walkthrough
R Code and Data
R Language and Rtools40 (click and "base" and "Rtools")
Download and install RStudio
Comments, Question and Request