Resultados
library(tidyverse)
library(covdata)
library(ggrepel)
library(paletteer)
Sys.setlocale(category = "LC_ALL", locale = "English_United States.1252")
## [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
## Countries to highlight
#focus_cn <- c("CHN", "DEU", "GBR", "USA", "JPN", "KOR", "ITA", "FRA", "ESP", "CHE", "BRA")
focus_cn <- c("CHN", "DEU", "GBR", "USA", "ITA", "ESP", "BRA")
## Colors
cgroup_cols <- c(prismatic::clr_darken(paletteer_d("ggsci::category20_d3"), 0.2)[1:length(focus_cn)], "gray70")
covnat %>%
filter(cu_cases > 100) %>%
mutate(days_elapsed = date - min(date),
end_label = ifelse(date == max(date), cname, NA),
end_label = recode(end_label, `United States` = "USA",
`Iran, Islamic Republic of` = "Iran",
`Korea, Republic of` = "South Korea",
`United Kingdom` = "UK"),
cname = recode(cname, `United States` = "USA",
`Iran, Islamic Republic of` = "Iran",
`Korea, Republic of` = "South Korea",
`United Kingdom` = "UK"),
end_label = case_when(iso3 %in% focus_cn ~ end_label,
TRUE ~ NA_character_),
cgroup = case_when(iso3 %in% focus_cn ~ iso3,
FALSE ~ "ZZOTHER")) %>%
ggplot(mapping = aes(x = days_elapsed, y = cu_cases,
color = cgroup, label = end_label,
group = cname)) +
geom_line(size = 0.5) +
geom_text_repel(nudge_x = 0.75,
segment.color = NA) +
guides(color = FALSE) +
scale_color_manual(values = cgroup_cols) +
scale_y_continuous(labels = scales::comma_format(accuracy = 1),
breaks = 2^seq(4, 19, 1),
trans = "log2") +
labs(x = "Days Since 100th Confirmed Case",
y = "Cumulative Number of Reported Cases (log2 scale)",
title = "Cumulative Reported Cases of COVID-19",
subtitle = paste("ECDC data as of", format(max(covnat$date), "%A, %B %e, %Y")),
caption = "Cid Póvoas / Data: https://www.ecdc.europa.eu/") +
theme_classic()
covnat %>%
filter(cu_cases > 100) %>%
mutate(days_elapsed = date - min(date),
end_label = ifelse(date == max(date), cname, NA),
end_label = recode(end_label, `United States` = "USA",
`Iran, Islamic Republic of` = "Iran",
`Korea, Republic of` = "South Korea",
`United Kingdom` = "UK"),
cname = recode(cname, `United States` = "USA",
`Iran, Islamic Republic of` = "Iran",
`Korea, Republic of` = "South Korea",
`United Kingdom` = "UK"),
end_label = case_when(iso3 %in% focus_cn ~ end_label,
TRUE ~ NA_character_),
cgroup = case_when(iso3 %in% focus_cn ~ iso3,
TRUE ~ "ZZOTHER")) %>%
ggplot(mapping = aes(x = days_elapsed, y = cu_cases,
color = cgroup, label = end_label,
group = cname)) +
geom_line(size = 0.5) +
geom_text_repel(nudge_x = 0.75,
segment.color = NA) +
guides(color = FALSE) +
scale_color_manual(values = cgroup_cols) +
scale_y_continuous(labels = scales::comma_format(accuracy = 1),
breaks = 2^seq(4, 19, 1),
trans = "log2") +
labs(x = "Days Since 100th Confirmed Case",
y = "Cumulative Number of Reported Cases (log2 scale)",
title = "Cumulative Reported Cases of COVID-19",
subtitle = paste("ECDC data as of", format(max(covnat$date), "%A, %B %e, %Y")),
caption = "Cid Póvoas / Data: https://www.ecdc.europa.eu/") +
theme_classic()