Last active
May 4, 2020 04:00
-
-
Save pimentel/6e86c2801845096aeed5f9e75ad05e3e to your computer and use it in GitHub Desktop.
Attempting to recreate M. Levitt Sweden COVID plot
This file contains 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
# reference: | |
library('cowplot') | |
library('dplyr') | |
library('ggplot2') | |
library('lubridate') | |
data <- read.csv("https://opendata.ecdc.europa.eu/covid19/casedistribution/csv", na.strings = "", fileEncoding = "UTF-8-BOM") | |
swe = filter(data, countryterritoryCode == 'SWE') | |
start_date = '2020-01-22' | |
swe = dplyr::mutate(swe, date_adj = dmy(as.character(dateRep))) | |
swe = dplyr::mutate(swe, days_since = time_length(start_date %--% date_adj, 'day')) | |
swe_pos = dplyr::filter(swe, days_since >= 0) | |
p = ggplot(swe_pos, aes(days_since, deaths)) | |
p = p + geom_point() | |
p = p + geom_line() | |
p = p + stat_smooth(span = 0.5, col = 'red') | |
p | |
save_plot(p, file = 'swe_since_2020-01-22.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment