-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.Rmd
462 lines (418 loc) · 12.9 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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
---
title: "Status Coronavirus di Indonesia"
author: "Aldilas Achmad N."
output:
flexdashboard::flex_dashboard:
orientation: rows
# social: ["facebook", "twitter", "linkedin"]
vertical_layout: fill
editor_options:
chunk_output_type: inline
---
```{r setup, include=FALSE}
library(tidyverse)
library(flexdashboard)
library(plotly)
library(googlesheets4)
library(gargle)
library(curl)
library(networkD3)
library(igraph)
library(htmlwidgets)
library(htmltools)
library(sf)
library(leaflet)
library(leafpop)
#library(readxl)
```
```{r parameters}
# Set colors
# https://www.w3.org/TR/css-color-3/#svg-color
confirmed_color <- "purple"
active_color <- "#1f77b4"
recovered_color <- "forestgreen"
death_color <- "red"
numtest_color <- "orange"
```
```{r data}
# designate project-specific cache
#options(gargle_oauth_cache = ".kawalcovidauth", gargle_oauth_email = "[email protected]")
gs4_auth(email = "[email protected]")
df <- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", sheet = "Statistik Harian") %>% rename(date = 1, case_daily = 2, case_cum = 5, recovered_daily = 8, recovered_cum = 9, death_daily = 12, death_cum = 13, test_daily = 25)
df$date <- as.Date(df$date, format = "%d %b")
# Data lokal pulau Jawa
provCaseCum <- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", range = "Timeline!A1:AI130") %>% rename(date = 1)
provCaseDaily <- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", range = "Timeline!A132:AI263", col_names = TRUE) %>% rename(date = 1)
provCaseDaily[is.na(provCaseDaily)] <- 0
provCaseDat <- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", range = "Kasus per Provinsi!B2:H38", col_names = TRUE)
provCaseDat[4,1] <- "Kepulauan Bangka Belitung"
provCaseDat[6,1] <- "Daerah Istimewa Yogyakarta"
provCaseDat[7,1] <- "Daerah Khusus Ibukota Jakarta"
#provRecoverCum <- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", sheet = "Timeline", range = cell_rows(50:68)) %>% rename(date = 1)
#provDeathCum<- read_sheet("1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw", sheet = "Timeline", range = cell_rows(90:111)) %>% rename(date = 1)
idn <- read_sf("D:/Analisis Data Transaksi Halodoc/idn_map/Indonesia_Polygon.shp")
provCaseDat <- provCaseDat %>% pivot_longer(cols = -`Provinsi Asal`, names_to = "type")
provCaseMap <- merge(idn, provCaseDat, all = TRUE)
#Google Mobility data
mobility <- read_csv("Global_Mobility_Report.csv") %>% filter(sub_region_1 == "Special Region of Yogyakarta")
```
Statistik Nasional
=======================================================================
Row {data-width=400}
-----------------------------------------------------------------------
### Confirmed {.value-box}
```{r}
valueBox(
value = paste(format(sum(df$case_daily, na.rm = T), big.mark = ","), "", sep = " "),
caption = "Total kasus terkonfirmasi",
icon = "fas fa-user-md",
color = active_color
)
```
### Recovered {.value-box}
```{r}
valueBox(
value = paste(format(sum(df$recovered_daily, na.rm=TRUE), big.mark = ","), " (", round(100 * sum(df$recovered_daily, na.rm = TRUE) / sum(df$case_daily, na.rm=TRUE), 1), "%)", sep = ""),
caption = "Jumlah kasus sembuh",
icon = "fas fa-laugh",
color = recovered_color)
```
### death {.value-box}
```{r}
valueBox(
value = paste(format(sum(df$death_daily, na.rm = TRUE), big.mark = ","), " (", round(100 * sum(df$death_daily, na.rm = TRUE) / sum(df$case_daily, na.rm = TRUE), 1), "%)", sep = ""),
caption = "Jumlah kasus meninggal",
icon = "fas fa-sad-tear",
color = death_color
)
```
### Num of Test {.value-box}
```{r}
valueBox(
value = paste(format(sum(df$test_daily, na.rm = TRUE), big.mark = ","), "", sep = " "),
caption = "Jumlah tes yang telah dilakukan",
icon = "fas fa-vial",
color = numtest_color
)
```
Row {data-width=400}
-----------------------------------------------------------------------
### **Laporan kasus kumulatif**
```{r message=FALSE, warning=FALSE}
plot_ly(data = df, x = ~date) %>%
add_trace(
y = ~case_cum,
type = "scatter",
mode = "lines+markers",
name = "Jumlah kasus Terkonfirmasi",
line = list(color = active_color),
marker = list(color = active_color)
) %>%
add_trace(
y = ~death_cum,
type = "scatter",
mode = "lines+markers",
name = "Jumlah kasus kematian",
line = list(color = death_color),
marker = list(color = death_color)
) %>%
add_trace(
y = ~recovered_cum,
type = "scatter",
mode = "lines+markers",
name = "Jumlah kasus sembuh",
line = list(color = recovered_color),
marker = list(color = recovered_color)
) %>%
add_annotations(
x = as.Date("2020-03-11"),
y = 3,
text = paste("Kematian pertama"),
xref = "x",
yref = "y",
arrowhead = 5,
arrowhead = 3,
arrowsize = 1,
showarrow = TRUE,
ax = 0,
ay = -90
) %>%
layout(
title = "",
yaxis = list(title = "Jumlah kasus kumulatif"),
xaxis = list(title = "Tanggal", range = c("2020-03-02", "2020-06-26")),
legend = list(x = 0.1, y = 0.9),
hovermode = "compare"
)
```
### **Laporan kasus harian**
```{r message=FALSE, warning=FALSE}
plot_ly(data = df, x = ~date) %>%
add_trace(
y = ~case_daily,
name = "Kasus terkonfirmasi baru",
type = "bar",
marker = list(color = active_color)
) %>%
add_trace(
y = ~death_daily,
name = "Kasus meninggal",
type = "bar",
marker = list(color = death_color)
) %>%
add_trace(
y = ~recovered_daily,
name = "Kasus sembuh",
type = "bar",
marker = list(color = recovered_color)
) %>%
add_trace(
y = ~test_daily,
name = "Jumlah test yang dilakukan",
type = "bar",
marker = list(color = numtest_color)
) %>%
add_annotations(
x = as.Date("2020-03-16"),
y = 3,
text = paste("Perubahan kriteria pemeriksaan"),
xref = "x",
yref = "y",
arrowhead = 5,
arrowhead = 3,
arrowsize = 1,
showarrow = TRUE,
ax = 0,
ay = -90
) %>%
layout(
title = "",
yaxis = list(title = "Jumlah kasus harian"),
xaxis = list(title = "Tanggal", range = c("2020-03-02", "2020-06-26")),
legend = list(x = 0.1, y = 0.9),
hovermode = "compare"
)
```
Statistik Provinsi
=======================================================================
Row {data-width=400}
-----------------------------------------------------------------------
### Perbandingan data kumulatif antar-provinsi di Pulau Jawa
```{r}
plot_ly(data = provCaseCum, x = ~date) %>%
add_trace(
y = ~Jakarta,
name = "DKI Jakarta",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = ~Banten,
name = "Banten",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = ~Jabar,
name = "Jawa Barat",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = ~Jateng,
name = "Jawa Tengah",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = ~DIY,
name = "DI Yogyakarta",
type = "scatter",
mode = "lines+markers"
) %>%
add_trace(
y = ~Jatim,
name = "Jawa Timur",
type = "scatter",
mode = "lines+markers"
) %>%
layout(
title = "",
yaxis = list(title = "Jumlah Kasus Kumulatif"),
xaxis = list(title = "Tanggal"),
legend = list(x = 0.1, y = 0.9),
hovermode = "compare"
)
```
### Perbandingan data harian antar-provinsi di Pulau Jawa
```{r}
plot_ly(data = provCaseDaily, x = ~date) %>%
add_trace(
y = ~Jakarta,
name = "DKI Jakarta",
type = "bar"
) %>%
add_trace(
y = ~Banten,
name = "Banten",
type = "bar"
) %>%
add_trace(
y = ~Jabar,
name = "Jawa Barat",
type = "bar"
) %>%
add_trace(
y = ~Jateng,
name = "Jawa Tengah",
type = "bar"
) %>%
add_trace(
y = ~DIY,
name = "DI Yogyakarta",
type = "bar"
) %>%
add_trace(
y = ~Jatim,
name = "Jawa Timur",
type = "bar"
) %>%
layout(
title = "",
yaxis = list(title = "Jumlah Kasus Kumulatif"),
xaxis = list(title = "Tanggal"),
legend = list(x = 0.1, y = 0.9),
hovermode = "compare"
)
```
Google Mobility Data
=======================================================================
Row {data-width=400}
-------------------------------------
### Daerah Istimewa Yogyakarta
```{r}
plot_ly(data = mobility, x = ~date) %>%
add_trace(
y = ~retail_and_recreation_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Tempat rekreasi"
) %>%
add_trace(
y = ~grocery_and_pharmacy_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Perbelanjaan dan Farmasi"
) %>%
add_trace(
y = ~parks_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Taman"
) %>%
add_trace(
y = ~transit_stations_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Transportasi"
) %>%
add_trace(
y = ~workplaces_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Tempat kerja"
) %>%
add_trace(
y = ~residential_percent_change_from_baseline,
type = "scatter",
mode = "lines",
name = "Pemukiman"
) %>%
add_trace(
data = provCaseDaily,
x = ~date,
y = ~DIY,
type = "bar",
name = "Kasus Harian Baru"
) %>%
add_annotations(
x = as.Date("2020-06-07"),
y = 3,
text = paste("Berita viral Malioboro padat pesepeda"),
xref = "x",
yref = "y",
arrowhead = 5,
arrowhead = 3,
arrowsize = 1,
showarrow = TRUE,
ax = 0,
ay = -90
) %>%
layout(
title = "Mobility Data Wilayah DIY Selama Pandemi",
yaxis = list(title = "Intensitas"),
xaxis = list(title = "Tanggal", rangeslider = list(type = "date"), range = c("2020-02-15", "2020-07-07")),
legend = list(x = 0.01, y = -0.0001),
hovermode = "compare"
)
```
<!-- Kluster Map -->
<!-- ======================================================================= -->
<!-- Row {data-width=400} -->
<!-- ------------------------------------- -->
<!-- ### Visualisasi Cluster Infeksi -->
<!-- ```{r} -->
<!-- idn.covidtracing <- read.csv("https://docs.google.com/spreadsheets/d/1ma1T9hWbec1pXlwZ89WakRk-OfVUQZsOCFl4FwZxzVw/export?format=csv&gid=0", sep=",", skip = 1) -->
<!-- idn.covidtracing$Sumber.Kontak <- ifelse(idn.covidtracing$Jenis.kasus == "Impor", "Impor", as.character(idn.covidtracing$Sumber.Kontak)) -->
<!-- tracing.network <- idn.covidtracing %>% select(No, Sumber.Kontak) -->
<!-- tracing.network$Sumber.Kontak <- ifelse(tracing.network$Sumber.Kontak == "", tracing.network$No, as.character(tracing.network$Sumber.Kontak)) -->
<!-- simpleNetwork(tracing.network, fontSize = 12, zoom = TRUE) -->
<!-- ``` -->
Peta Kasus Seluruh Indonesia
=======================================================================
Row {data-width=400}
-------------------------------------
### **Jumlah kasus di seluruh dunia**
```{r message=FALSE, warning=FALSE}
cv_data_for_plot <- st_centroid(provCaseMap) %>%
dplyr::mutate(log_cases = 2 * log(value))
cv_data_for_plot.split <- cv_data_for_plot %>% split(cv_data_for_plot$type)
pal <- colorFactor(c("orange", "red", "green"), domain = c("Kasus", "Kematian", "Sembuh"))
map_object <- leaflet() %>% addProviderTiles(providers$Stamen.Toner)
names(cv_data_for_plot.split) %>%
purrr::walk(function(df) {
map_object <<- map_object %>%
addCircleMarkers(
data = cv_data_for_plot.split[[df]],
color = ~pal(type),
stroke = FALSE,
fillOpacity = 0.8,
radius = ~log_cases,
popup = leafpop::popupTable(cv_data_for_plot.split[[df]],
feature.id = FALSE,
row.numbers = FALSE,
zcol = c("type", "value", "locname")
),
group = df,
labelOptions = labelOptions(
noHide = F,
direction = "auto"
)
)
})
map_object %>%
addLayersControl(
overlayGroups = names(cv_data_for_plot.split),
options = layersControlOptions(collapsed = FALSE)
)
```
Tentang Dasbor
=======================================================================
**Dasbor Situasi Coronavirus di Indonesia**
Dasbor ini merupakan visualisasi data mengenai epidemi COVID-19 yang sedang berlangsung di Indonesia. Dasbor ini dikembangkan menggunakan piranti lunak R. Pengembangan dasbor ini diadaptasi dari [dasbor](https://ramikrispin.github.io/coronavirus_dashboard/){target="_blank"} yang dikembangkan oleh Rami Krispin.
**Data**
Data yang digunakan untuk pengembangan dasbor ini menggunakan data yang dikumpulkan oleh relawan [KawalCovID19](https://kawalcovid19.id){target="_blank"} dan juga dataset dari pustaka R [`{coronavirus}`](https://github.com/RamiKrispin/coronavirus){target="_blank"}
Data akan selalu diupdate setiap hari.
Data mentah diambil dari data yang disediakan Johns Hopkins University Center for Systems Science and Engineering (JHU CCSE) Coronavirus [repositori](https://github.com/RamiKrispin/coronavirus-csv){target="_blank"}.
**Kontak**
Untuk mengetahui kode sumber dasbor ini dapat mengunjungi [Github](https://github.com/aldeetropolis/flexboard-covid-id){target="_blank"}.