Created
January 12, 2022 19:20
-
-
Save MJacobs1985/1effb086e5071fa1f92015fd7ff89d3e to your computer and use it in GitHub Desktop.
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
| rm(list = ls()) | |
| library(tidyverse) | |
| library(readr) | |
| library(ggthemes) | |
| library(lubridate) | |
| library(zoo) | |
| getwd() | |
| data_folder <- file.path("") | |
| url <- "https://covid.ourworldindata.org/data/owid-covid-data.csv" | |
| name <- "owid-covid-data.csv" | |
| download.file(url = url, destfile = paste0(data_folder,name)) | |
| setwd(data_folder) | |
| Covidowid_covid_data <- read_csv(paste0(data_folder,name)) | |
| df<-Covidowid_covid_data | |
| countries <- c(unique(df_owid$iso_code)) | |
| dfNLD <- df%>% | |
| dplyr::filter(iso_code == "NLD")%>% | |
| dplyr::select(date,iso_code,date,new_cases_per_million, new_deaths_per_million)%>% | |
| dplyr::mutate(cases_07da = zoo::rollmean(new_cases_per_million, k = 7, fill = NA), | |
| deaths_07da = zoo::rollmean(new_deaths_per_million, k = 7, fill = NA), | |
| deathdate_21plus = date - 21) | |
| ggplot(dfNLD)+ | |
| geom_line(aes(x=date, y=log(cases_07da), colour="New Cases"))+ | |
| geom_line(aes(x=deathdate_21plus, y=log(deaths_07da), colour="New Deaths"))+ | |
| scale_colour_manual(name="", | |
| values=c('red', 'grey'), | |
| labels = c("Cases", "Deaths 21 days later"))+ | |
| theme_bw()+ | |
| theme(legend.position="bottom")+ | |
| labs(x="Date", | |
| y="New Cases and New Deaths (log Scale)", | |
| title="New Cases vs New Deaths on a 7-day moving average log scale") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment