Data source: ECDC. Data set is freely available via ECDC website
library(tidyverse) # Load tidyverse package
df <- read_csv('mpx.csv') # Load data set (public data on monkeypox cases in the EU/EEA via ECDC)
Number of reported cases in the Czech Republic (only dates when at least one case was reported is printed)
# Cases in the Czech Republic alone
df_cz <- df %>%
filter(CountryCode == 'CZ')
df_cz_cases <- df_cz %>%
filter(ConfCases > 0)
df_cz_cases
df_cz %>%
ggplot(aes(y = ConfCases, x = DateRep, fill = CountryCode)) + geom_bar(stat = 'identity', width = 0.9) + labs(title = 'Reported MPX cases in Czech Republic', x = 'Month', y = 'Confirmed cases', fill = 'Country code') + scale_x_date(date_breaks = "1 month", date_labels = "%m/%y") + theme_minimal()
Plot for all EU/EEA countries
df %>%
ggplot(aes(x = DateRep, y = ConfCases)) + geom_point(aes(size = ConfCases, color = CountryCode)) + labs(title = 'Reported MPX cases in EU/EEA countries', x = 'Month', y = 'Confirmed cases', size = 'Number of cases', color = 'Country code') + scale_x_date(date_breaks = "1 month", date_labels = "%m/%y") + theme_minimal()
Ordering countries by the total number of cases:
df %>%
group_by(CountryCode) %>%
summarize(tot = sum(ConfCases)) %>%
ungroup() %>%
arrange(desc(tot))
Plot of reported cases from countries with highest number of reported cases (ES, DE, FR) and CZ
df_selected <- df %>%
filter(CountryCode == 'DE' | CountryCode == 'FR' | CountryCode == 'ES' | CountryCode == 'CZ')
df_selected %>%
ggplot(aes(x = DateRep, y = ConfCases)) + geom_point(aes(size = ConfCases, color = CountryCode)) + labs(title = 'Reported MPX cases in ES, DE, FR, CZ', x = 'Month', y = 'Confirmed cases', size = 'Number of cases', color = 'Country code') + scale_x_date(date_breaks = "1 month", date_labels = "%m/%y") + theme_minimal()
Plot of reported cases from selected countries with regression lines:
df_selected %>%
ggplot(aes(x = DateRep, y = ConfCases, color = CountryCode)) + geom_point() + geom_smooth(se = FALSE, method = lm) + labs(title = 'Reported MPX cases in selected countries (with regression lines)', x = 'Month', y = 'Confirmed cases', color = 'Country code') + scale_x_date(date_breaks = "1 month", date_labels = "%m/%y") + theme_minimal()
## `geom_smooth()` using formula 'y ~ x'