-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
new_cases.R
75 lines (69 loc) · 2.85 KB
/
new_cases.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# required packages
library(ggplot2)
library(ggrepel)
library(zoo)
library(lme4)
library(dplyr)
# import data
dat <- read.csv("https://epistat.sciensano.be/Data/COVID19BE_CASES_AGESEX.csv")
# aggregate new cases by province and date
dat <- aggregate(CASES ~ DATE + PROVINCE, dat, sum)
# add new cases for Belgium as a whole
belgium <- aggregate(CASES ~ DATE, dat, sum)
belgium$PROVINCE <- "Belgium"
col_order <- c("DATE", "PROVINCE", "CASES")
belgium <- belgium[, col_order]
dat <- rbind(dat, belgium)
# transform date and provinces
dat$DATE <- as.Date(dat$DATE)
dat$PROVINCE <- factor(dat$PROVINCE,
levels = c("Antwerpen",
"BrabantWallon",
"Brussels",
"Hainaut",
"Li\xe8ge",
"Limburg",
"Luxembourg",
"Namur",
"OostVlaanderen",
"VlaamsBrabant",
"WestVlaanderen",
"Belgium"),
labels = c("Antwerpen",
"Brabant wallon",
"Brussels",
"Hainaut",
"Liège",
"Limburg",
"Luxembourg",
"Namur",
"Oost-Vlaanderen",
"Vlaams-Brabant",
"West-Vlaanderen",
"Belgium"))
# Create plot in english
ggplot(dat) +
aes(x = DATE, weight = CASES) +
geom_bar(fill = "steelblue") +
theme_minimal() +
facet_wrap(vars(PROVINCE), scales = "free_y") +
geom_line(aes(y = rollmean(CASES, 5, fill = NA))
, color = "#0c4c8a") +
labs(x = "", y = "Confirmed new cases") +
labs(
title = "Evolution of daily confirmed new cases (5-day moving average) - COVID-19",
caption = "Niko Speybroeck (@NikoSpeybroeck), Antoine Soetewey (@statsandr) & Angel Rosas (@am_rosasa)\n
Data: https://epistat.wiv-isp.be/covid/")
# Create plot in ndls/fr
ggplot(dat) +
aes(x = DATE, weight = CASES) +
geom_bar(fill = "steelblue") +
theme_minimal() +
facet_wrap(vars(PROVINCE), scales = "free_y") +
geom_line(aes(y = rollmean(CASES, 5, fill = NA))
, color = "#0c4c8a") +
labs(x = "", y = "Nouveaux cas confirmés / Bevestigde nieuwe gevallen") +
labs(
title = "Evolution des nouveaux cas confirmés / Evolutie van nieuwe bevestigde gevallen - COVID-19",
caption = "Niko Speybroeck (@NikoSpeybroeck), Antoine Soetewey (@statsandr) & Angel Rosas (@am_rosasa)\n
Data: https://epistat.wiv-isp.be/covid/")