-
Notifications
You must be signed in to change notification settings - Fork 0
/
3_caricom_covid19_flexdashboard_V4.Rmd
362 lines (298 loc) · 14.3 KB
/
3_caricom_covid19_flexdashboard_V4.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
---
title: 'CARICOM COVID-19 Dashboard'
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
theme: yeti
---
```{r setup, include=FALSE}
library(flexdashboard)
source("https://git.io/Jfqjv", local = T)
```
Overview
=====================================
Row
-----------------------------------------------------------------------
### Confirmed Cases in CARICOM
```{r}
valueBox(caricom_totals$total_confirmed, icon = "fa-ambulance",
href = "#growth")
```
### Active Cases in CARICOM
```{r}
valueBox(caricom_totals$total_active, icon = "fa-hospital", color = "warning",
href = "#caricom-map")
```
### Total Recoveries in CARICOM
```{r}
valueBox(caricom_totals$total_recovered, icon = "fa-male", color = "success",
href = "#recovery")
```
### Confirmed Deaths in CARICOM
```{r}
valueBox(caricom_totals$total_deaths, icon = "fa-skull", color = "danger",
href = "#caricom-map")
```
CARICOM Map
=====================================
Column {data-width=600}
-----------------------------------------------------------------------
### Spatial Distribution of COVID-19
```{r}
library(leaflet)
library(leaflet.extras)
caricom_covid_map <- leaflet() %>%
addProviderTiles(providers$CartoDB.VoyagerLabelsUnder) %>%
addMarkers(lat = caricom_today$lat,
lng = caricom_today$lng,
popupOptions = markerClusterOptions,
popup = paste("<b>", caricom_today$country, "</b> <br>",
"Date: ", caricom_today$date, "<br>",
"Confirmed Cases: ", caricom_today$confirmed, "<br>",
"Deaths:", caricom_today$deaths,"<br>",
"Recovered", caricom_today$recovered,"<br>",
"Income Group:", caricom_today$income, "<br>",
"Population Aged 65+:", caricom_today$pop_65_over_2018,"<br>",
"Diabetes prev. (% pop 20-79):", caricom_today$diabetes_20_79)) %>%
addCircleMarkers(lat = caricom_today$lat,
lng = caricom_today$lng,
weight = 1,
radius = log(caricom_today$confirmed_per_100k)*8,
color = 'yellow') %>%
addCircleMarkers(lat = caricom_today$lat,
lng = caricom_today$lng,
weight = 1,
radius = caricom_today$deaths_per_100k,
color = 'red') %>%
addLegend("bottomright",
colors= c('red', 'yellow'),
labels= c('Deaths per 100,000', 'Confirmed Cases per 100,000'),
title="Legend")
caricom_covid_map
```
Column {data-width=400}
-----------------------------------------------------------------------
### Breakdown of Total Today
```{r}
library(plotly)
horizontal_barplot <- caricom_tidycovid19_cases %>%
filter(date == max(date)) %>%
ggplot(
aes(x = country,
y = value,
fill = cases))+
labs(x = "Total Cases by Status",
y = "Member State") +
geom_bar(position = "stack",
stat = "identity") +
coord_flip()
ggplotly(horizontal_barplot)
```
Growth
=====================================
Row
-----------------------------------------------------------------------
### Daily Increase in Cumulative Cases among Worst Affected CARICOM Member States
```{r}
library(plotly)
gg <- caricom_tidycovid19 %>%
mutate(cases_logratio = difference(log(confirmed))) %>%
filter(iso3c %in% top_6) %>%
filter(date >= as.Date("2020-03-15")) %>%
ggplot(aes(x = date, y = cases_logratio, col = country)) +
geom_smooth(method = "loess", se = FALSE) +
labs(x = "Date",
y = "Daily Growth in Cumulative Cases (%)") +
scale_y_continuous(
"Daily increase in cumulative cases",
breaks = log(1+seq(0,60,by=10)/100),
labels = paste0(seq(0,60,by=10),"%")) +
ggthemes::scale_color_colorblind()
ggplotly(gg) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
Row
-----------------------------------------------------------------------
### Evolution of Confirmed Cases Among CARICOM Member States
```{r}
library(highcharter)
hc_area <- caricom_totals_ts %>%
select(-total_confirmed) %>%
gather(cases, value, total_deaths, total_recovered, total_active) %>%
hchart("area",
hcaes(x = date, y = value, group =cases)) %>%
hc_plotOptions(area = list(
stacking = "normal",
lineColor = "#ffffff",
lineWidth = 1,
marker = list(
lineWidth = 1,
lineColor = "#ffffff"
))
) %>% hc_add_theme(hc_theme_elementary())
hc_area
```
### Treemap of Confirmed Cases Among CARICOM Member States Today
```{r}
hchart(caricom_today, "treemap", hcaes(x = iso3c, value = confirmed , color = confirmed)) %>% hc_add_theme(hc_theme_smpl())
```
Recovery
=====================================
Row
-----------------------------------------------------------------------
### Recovery and Mortality Rate
```{r}
library(plotly)
bubble <- plot_ly(caricom_today,
y = ~ round(recovery_rate, 1),
x = ~ round(mortality_rate, 1),
size = ~ log(confirmed),
sizes = c(5, 70),
type = 'scatter', mode = 'markers',
color = ~ country,
marker = list(sizemode = 'diameter' , opacity = 0.5),
hoverinfo = 'text',
text = ~paste("", country,
" Confirmed Cases: ", confirmed,
" Recovery Rate: ", paste(round(recovery_rate, 1), "%", sep = ""),
" Mortality Rate: ", paste(round(mortality_rate, 1), "%", sep = ""))
) %>%
layout(yaxis = list(title = "Recovery Rate", ticksuffix = "%"),
xaxis = list(title = "Death Rate", ticksuffix = "%",
dtick = 1,
tick0 = 0),
hovermode = "compare")
bubble
```
Row
-----------------------------------------------------------------------
### Mortality and Recovery by Income and Economy Type
```{r}
library(knitr)
kable(summarise(by_economy_type, mean(confirmed_per_100k), mean(mortality_rate), mean(recovery_rate)))
kable(summarise(by_income, mean(confirmed_per_100k), mean(mortality_rate), mean(recovery_rate)))
kable(summarise(by_oecs, mean(confirmed_per_100k), mean(mortality_rate), mean(recovery_rate)))
```
Impact of Restrictions {.tabset}
=====================================
The [**Google Community Mobility Reports**](https://www.google.com/covid19/mobility/) aim to provide insights into what has changed in response to policies aimed at combating COVID-19. The data allows for the tracking of movement movement trends over time by geography, across different categories of places such as retail and recreation, groceries and pharmacies, parks, transit stations, workplaces, and residential.This dataset is intended to help remediate the impact of COVID-19.
Row {.tabset .tabset-fade}
-------------------------------------
-------------------------------------
### Residential activity
```{r}
residential_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_residential , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
ggtitle("Mobility Changes around Residential among Worst Affected CARICOM Member States") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = "Mobility Changes to Residential among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(residential_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
### Recreational Activity
```{r}
recreation_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_retail_recreation , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = "Mobility Changes to Recreational Areas among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(recreation_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
### Workplace activity
```{r}
workplaces_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_workplaces , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
ggtitle("Mobility Changes around Workplaces among Worst Affected CARICOM Member States") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = " Mobility Changes to Workplaces among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(workplaces_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
### Public Parks
```{r}
parks_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_parks , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = "Mobility Changes to Public Parks among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(parks_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
### Transit Stations
```{r}
parks_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_transit_stations , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = "Mobility Changes to Transit Stations among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(parks_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
### Groceries and Pharmacies
```{r}
parks_facet <- caricom_tidycovid19 %>%
filter(iso3c %in% top_6,
date >= as.Date("2020-03-01")) %>%
ggplot(aes(x = date, y = gcmr_grocery_pharmacy , col = country)) +
geom_smooth(method = "loess") +
xlab("Date") +
ylab("Percentage Change Compared to Baseline") +
labs(caption = "Source: Google COVID-19 Community Mobility Reports
Prepared by: Yohance Nicholas",
title = "Mobility Changes to Groceries and Pharmacies among Worst Affected CARICOM Member States") +
ggthemes::scale_color_colorblind()
library(plotly)
ggplotly(parks_facet) %>%
layout(legend = list(orientation = "h", x = 0.1, y = -0.15))
```
About
=====================================
**Overview**
This Dashboard was created in partial fulfilment of the [Developing Data Products Course](https://www.coursera.org/learn/data-products/home/welcome) which comprises one of the five courses necessary for the Data Science: Statistics and Machine Learning Specialization offered by Johns Hopikins University through Coursera. This assignment challenged candidates to Create a data product and a reproducible pitch. Once completed, candidates were required to host their webpage on either GitHub Pages, RPubs, or NeoCities. The webpage presentation must contain the date that you created the document, and it must contain a plot created with Plotly.All other coursework projects completed as part of this course can be found at my [GitHub repository](https://yohance-nicholas.github.io/Developing-Data-Products/) for this course.
**Rationale**
The Coronavirus disease 2019 (COVID-19) is an infectious disease caused by severe acute respiratory syndrome coronavirus 2 (SARS-CoV-2). The disease was first identified in December 2019 in Wuhan, the capital of China's Hubei province, and has since spread globally, resulting in the ongoing 2019–20 coronavirus pandemic. For this coursework project, I have opted to use Plotly to illustrate the spread of the Novel Coronavirus across [CARICOM Member States](https://caricom.org/member-states-and-associate-members/). All CARICOM countries are classified as developing countries. They are all relatively small in terms of population and size, and diverse in terms of geography and population, culture and levels of economic and social development. While the pandemic was slow to reach the CARICOM region, the begining of March saw the onset of the pandemic among CARICOM member states.
**Data Sources**
With a view to map the spread of the disease thus far, I have elected to use two main data sources. Firstly, to obtain the most current data on the incidence of COVID-19, I have opted to utilise the data colelcted by the [Johns Hopkins Coronavirus Resource Centre](https://coronavirus.jhu.edu/). The [2019 Novel Coronavirus COVID-19 (2019-nCoV) Data Repository by Johns Hopkins CSSE](https://github.com/CSSEGISandData/COVID-19) is compiled from a cross section of sources daily. To supplement this data with relevant socio-demographic data, I have opted to utilise the [World Development Indicator Database](http://datatopics.worldbank.org/world-development-indicators/) maintained by the World Bank Group. The World Development Indicators is a compilation of relevant, high-quality, and internationally comparable statistics about global development and the fight against poverty. The database contains 1,600 time series indicators for 217 economies and more than 40 country groups, with data for many indicators going back more than 50 years.
**Data Cleaning**
A number of specialised data cleaning scripts were prepared to garner current data on a range of issues. These scripts can be found in the [GitHub repository](https://yohance-nicholas.github.io/Developing-Data-Products/) created to store the content and code generated in the completion of this course.
**Developer**
Yohance Nicholas | Consultant Economist @ [Kairi Consultants Limited](https://www.kairi.com) | [LinkedIn](https://www.linkedin.com/in/yohance-nicholas/) | [GitHub](https://yohance-nicholas.github.io/Developing-Data-Products/)