-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
403 lines (350 loc) · 17.2 KB
/
index.Rmd
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
---
title: "Covid-19 County Case Tracker"
runtime: shiny
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## About
While many sources are providing national data on the UK coronavirus outbreak, these figures are largely driven by the huge amount of cases in major cities. In order to see the real impact of Covid-19 on your local community, **this application provides visualisations of the coronavirus data that has been made available for counties in England, and health boards in Scotland and Wales.** Over the coming months, these visualisations will help to track how your community's efforts are helping to flatten your county's specific Covid-19 curve.
All Covid-19 data for English counties has been sourced from the UK Department of Health and Social Care, all data for Scottish counties has been sourced from the Scottish Government, and all data for Welsh counties has been sourced from Public Health Wales.
## England County Covid-19 Data (Scotland, Wales Below)
As of June 7th 2020, this data is up-to-date with the official figures released by the UK Department of Health and Social Care.
**On May 30th, the Department of Health and Social Care removed a considerable number of cases from the data. The reason for this has been given on their website as: **
***'... it has been identified that a group of test results from the previous 2 months, from a single NHS laboratory, were incorrectly reported to the national data-set as positive. Only a small proportion (<1%) of cases has been removed from the cumulative England total, but for some areas in the West Midlands (the region affected by this data correction), the proportions of cases removed will be greater.'***
**This may explain a large drop in cases for West Midlands counties seen in the plots below (for example, Birmingham) on May 30th.**
**On May 31st, it seems these figures were revised downwards again. It is currently not been made clear why.**
Select your county from the drop-down menu:
```{r eruptions, echo=FALSE}
library(dplyr, warn.conflict = FALSE)
library(ggplot2, warn.conflict = FALSE)
library(bbplot, warn.conflict = FALSE)
library(tidyr, warn.conflict = FALSE)
path_eng <- "https://coronavirus.data.gov.uk/downloads/csv/coronavirus-cases_latest.csv"
eng_cases <- suppressMessages(readr::read_csv(file = path_eng)) %>%
filter(`Area type` == "Upper tier local authority") %>%
mutate(date = lubridate::ymd(`Specimen date`)) %>%
select(date, region = "Area name", cases = "Cumulative lab-confirmed cases") %>%
arrange(date)
counties <- sort(unique(eng_cases$region))
selectInput(
'county', label = 'County:',
choices = counties, selected = "Oxfordshire"
)
renderPlot({
cases <- eng_cases %>%
rename(local = cases) %>%
mutate(imported = 0)
cases <- data.table::as.data.table(cases)
cases <- cases[region==input$county]
full_cases <- cases %>%
complete(date = seq.Date(min(date), max(date), by="day")) %>%
fill(`region`) %>%
fill(`local`) %>%
filter(date >= "2020-03-09")
cases <- full_cases$local
dates <- seq.Date(min(full_cases$date), max(full_cases$date), by = "day")
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ypos = max(cases) - 0.005*diff(range(cases))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$county, "Covid-19 Cases"), title = paste(input$county, "Total Covid-19 Cases (Linear Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[dates=="2020-03-23"]), linetype=2) +
annotate(geom="label", x=dates[dates=="2020-03-23"], label="UK lockdown begins", y=ypos, fontface="italic", colour="grey10", hjust=1.03, vjust=1, size=5) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
cases <- eng_cases %>%
rename(local = cases) %>%
mutate(imported = 0)
cases <- data.table::as.data.table(cases)
cases <- cases[region==input$county]
full_cases <- cases %>%
complete(date = seq.Date(min(date), max(date), by="day")) %>%
fill(`region`) %>%
fill(`local`) %>%
filter(date >= "2020-03-09")
cases <- full_cases$local
dates <- seq.Date(min(full_cases$date), max(full_cases$date), by = "day")
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
labs(x = "Date", y = paste(input$county, "Covid-19 Cases"), title = paste(input$county, "Total Covid-19 Cases (Logarithmic Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(trans = 'log2') +
geom_hline(yintercept = 0, size = 2, colour="#333333") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[dates=="2020-03-23"]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
cases <- eng_cases %>%
rename(local = cases) %>%
mutate(imported = 0)
cases <- data.table::as.data.table(cases)
cases <- cases[region==input$county]
full_cases <- cases %>%
complete(date = seq.Date(min(date), max(date), by="day")) %>%
fill(`region`) %>%
fill(`local`) %>%
filter(date >= "2020-03-09")
cases <- full_cases$local
dates <- seq.Date(min(full_cases$date), max(full_cases$date), by = "day")
A <- cases[-1]
B <- cases[-length(cases)]
diff <- c(0, A-B)
diff[diff==-1] <- 0
diff[1] <- NA
cases <- diff
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_bar(stat="identity",colour = "white",fill="steelblue") +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$county, "Covid-19 Cases"), title = paste(input$county, "Daily Covid-19 Cases")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[dates=="2020-03-23"]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
cases <- eng_cases %>%
rename(local = cases) %>%
mutate(imported = 0)
cases <- data.table::as.data.table(cases)
cases <- cases[region==input$county]
full_cases <- cases %>%
complete(date = seq.Date(min(date), max(date), by="day")) %>%
fill(`region`) %>%
fill(`local`) %>%
filter(date >= "2020-03-09")
cases <- full_cases$local
dates <- seq.Date(min(full_cases$date), max(full_cases$date), by = "day")
A <- cases[-1]
B <- cases[-length(cases)]
diff <- c(0, A/B)
diff[is.na(diff) | diff=="Inf"] <- 0
diff <- diff - 1
diff[diff==-1] <- 0
diff[1] <- NA
cases <- diff
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$county, "Covid-19 Cases"), title = paste(input$county, "Daily % Change (On Previous Day's Total)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(labels = scales::percent) +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[dates=="2020-03-23"]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
```
## Scotland Health Board Covid-19 Data
As of June 7th 2020, this data is up-to-date with the official figures released by the Scottish Government.
Select your health board from the drop-down menu:
```{r scottish_eruptions, echo=FALSE}
scottish_data <- read.csv("scotland_covid_data.csv", row.names=1)
scottish_counties <- sort(row.names(scottish_data))
selectInput(
'region', label = 'Health Board:',
choices = scottish_counties, selected = "Greater Glasgow and Clyde"
)
renderPlot({
cases <- as.matrix(scottish_data)[input$region,]
dates <- seq(as.Date("2020/03/09"), by = "days", length.out = length(scottish_data[input$region,]))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ypos = max(cases) - 0.005*diff(range(cases))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$region, "Covid-19 Cases"), title = paste(input$region, "Total Covid-19 Cases (Linear Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[15]), linetype=2) +
annotate(geom="label", x=dates[15], label="UK lockdown begins", y=ypos, fontface="italic", colour="grey10", hjust=1.03, vjust=1, size=5) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
cases <- as.matrix(scottish_data)[input$region,]
dates <- seq(as.Date("2020/03/09"), by = "days", length.out = length(scottish_data[input$region,]))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
labs(x = "Date", y = paste(input$region, "Covid-19 Cases"), title = paste(input$region, "Total Covid-19 Cases (Logarithmic Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(trans = 'log2') +
geom_hline(yintercept = 0, size = 2, colour="#333333") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[15]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
A <- scottish_data[,-1]
B <- scottish_data[,-length(scottish_data)]
zeros <- integer(length(scottish_counties))
diff <- cbind(zeros, A-B)
cases <- as.matrix(diff)[input$region,]
dates <- seq(as.Date("2020/03/09"), by = "days", length.out = length(cases))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_bar(stat="identity",colour = "white",fill="steelblue") +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$region, "Covid-19 Cases"), title = paste(input$region, "Daily Covid-19 Cases")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[15]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
A <- scottish_data[,-1]
B <- scottish_data[,-length(scottish_data)]
zeros <- integer(length(scottish_counties))
diff <- cbind(zeros, A/B)
diff[is.na(diff) | diff=="Inf"] <- 0
diff <- diff - 1
diff[diff==-1] <- 0
diff[,1] <- NA
cases <- as.matrix(diff)[input$region,]
dates <- seq(as.Date("2020/03/09"), by = "days", length.out = length(cases))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$region, "Covid-19 Cases"), title = paste(input$region, "Daily % Change (On Previous Day's Total)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(labels = scales::percent) +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[15]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
```
## Wales Health Board Covid-19 Data
As of June 7th 2020, this data is up-to-date with the official figures released by Public Health Wales.
Select your health board from the drop-down menu:
```{r welsh_eruptions, echo=FALSE}
welsh_data <- read.csv("wales_covid_data.csv", row.names=1)
welsh_counties <- sort(row.names(welsh_data))
selectInput(
'welsh_region', label = 'Health Board:',
choices = welsh_counties, selected = "Aneurin Bevan"
)
renderPlot({
cases <- as.matrix(welsh_data)[input$welsh_region,]
dates <- seq(as.Date("2020/03/20"), by = "days", length.out = length(welsh_data[input$welsh_region,]))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ypos = max(cases) - 0.005*diff(range(cases))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$welsh_region, "Covid-19 Cases"), title = paste(input$welsh_region, "Total Covid-19 Cases (Linear Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[4]), linetype=2) +
annotate(geom="label", x=dates[4], label="UK lockdown begins", y=ypos, fontface="italic", colour="grey10", hjust=-0.03, vjust=1, size=5) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
cases <- as.matrix(welsh_data)[input$welsh_region,]
dates <- seq(as.Date("2020/03/20"), by = "days", length.out = length(welsh_data[input$welsh_region,]))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
labs(x = "Date", y = paste(input$welsh_region, "Covid-19 Cases"), title = paste(input$welsh_region, "Total Covid-19 Cases (Logarithmic Scale)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(trans = 'log2') +
geom_hline(yintercept = 0, size = 2, colour="#333333") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_point(data = last_point, aes(x = dates, y = cases), col = "#007f7f", shape = 21, fill = "white", size = 2, stroke = 1.7) +
geom_text(data = last_point, aes(x = dates, y = cases, label = cases), size = 6, vjust = 2.0, nudge_x = 0.5) +
geom_vline(data=df, xintercept=as.numeric(dates[4]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
A <- welsh_data[,-1]
B <- welsh_data[,-length(welsh_data)]
zeros <- integer(length(welsh_counties))
diff <- cbind(zeros, A-B)
cases <- as.matrix(diff)[input$welsh_region,]
dates <- seq(as.Date("2020/03/20"), by = "days", length.out = length(cases))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_bar(stat="identity",colour = "white",fill="steelblue") +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$welsh_region, "Covid-19 Cases"), title = paste(input$welsh_region, "Daily Covid-19 Cases")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[4]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
renderPlot({
A <- welsh_data[,-1]
B <- welsh_data[,-length(welsh_data)]
zeros <- integer(length(welsh_counties))
diff <- cbind(zeros, A/B)
diff[is.na(diff) | diff=="Inf"] <- 0
diff <- diff - 1
diff[diff==-1] <- 0
diff[,1] <- NA
cases <- as.matrix(diff)[input$welsh_region,]
dates <- seq(as.Date("2020/03/20"), by = "days", length.out = length(cases))
df <- data.frame(dates,cases)
last_point <- df %>% # most recent value
slice(which.max(dates))
ggplot(df, aes(x = dates, y = cases)) +
geom_line(colour = "#007f7f", size = 1) +
geom_hline(yintercept = 0, size = 1, colour="#333333") +
labs(x = "Date", y = paste(input$welsh_region, "Covid-19 Cases"), title = paste(input$welsh_region, "Daily % Change (On Previous Day's Total)")) +
scale_x_date(date_breaks = "4 days", date_labels = "%d/%m") +
scale_y_continuous(labels = scales::percent) +
theme(axis.text.x = element_text(angle = 90, vjust=0.5, hjust=1)) +
geom_vline(data=df, xintercept=as.numeric(dates[4]), linetype=2) +
bbc_style() +
theme(plot.title = element_text(hjust = 0.5, size=20))
})
```