-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
260 lines (198 loc) · 8.6 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
---
title: "Crna Gora COVID-19"
featuredImage: "Users/Dovla/Desktop/img.png"
author: "W"
output:
flexdashboard::flex_dashboard:
theme: cosmo
orientation: rows
social: menu
source_code: embed
---
```{r setup, include=FALSE}
library(ggplot2)
library(plotly)
library(plyr)
library(flexdashboard)
library(tidyverse)
library(leaflet)
library(stringr)
library(sf)
library(here)
library(widgetframe)
library(tidyr)
library(DT)
mne <- read.csv("/Users/Dovla/Desktop/covidMNE2703.csv")
```
Mapa oboljelih
=======================================================================
Row
-----------------------------------------------------------------------
### Samoizolacija
```{r}
articles <- 7398
valueBox(articles, icon = "fa-home", color = "success")
```
### COVID-19 slucajevi
```{r}
comments <- 262
valueBox(comments, icon = "fa-notes-medical", color = "warning")
```
### Umrli
```{r}
spam <- 2
valueBox(spam,
icon = "fa-battery-empty",
color = "danger")
```
Row
-----------------------------------------------------------------------
### Mapa
```{r,fig.width = 12, echo=FALSE, warning=FALSE}
#gra <- data.frame("gr"=c("Podgorica","Tuzi","Ulcinj","Andrijevica","Bar","Budva","Herceg Novi","Danilovgrad","Tivat","Bijelo Polje","Niksic"),"nr" = c(49,33,8,7,10,4,4,1,2,1,1))
gra <- read.csv('/Users/Dovla/Desktop/covid19-mne/tweetStatus.csv')
b <-c()
for(i in 1:nrow(gra)) {
b <- c(b,rep(paste0(gra$gr[i]),gra$nr[i]))
}
gra2 <- data.frame(unlist(b))
colnames(gra2) <- "gr"
grad <- read.csv("/Users/Dovla/Desktop/grad.csv")
grad1 <- unique(grad)
mapa <- left_join(gra2, grad1, by = c("gr" = "Grad"))
#mapa <- na.omit(read.csv("/Users/Dovla/Desktop/grad.csv"))
m <- leaflet() %>%
addTiles(urlTemplate = 'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png')
#m %>%
# frameWidget()
leaflet(data = mapa) %>%
addTiles() %>%
addMarkers(clusterOptions = markerClusterOptions()) #%>% frameWidget()
```
### Novi COVID-19 slucajevi
```{r}
mne22 <- subset(mne[mne$InfectedNew>0,])
p3 <- ggplot(data=mne22, aes(x=Day, y=InfectedNew)) + geom_bar(stat="identity",color="red", fill="white") +
labs(x="Dana od 9/3 tj epidemije", y = "Novih slucajeva") + coord_flip()
ggplotly(p3)
```
Podaci JIZCG
=======================================================================
Row
-----------------------------------------------------------------------
### Evolucija COVID-19 slucajeva
```{r}
mne <- read.csv("/Users/Dovla/Desktop/covidMNE2703.csv")
mne$InfectionRate1 <- as.numeric(levels(mne$InfectionRate))[mne$InfectionRate]
myvars <- c("Day","Infected", "Tested")#, "UnderWatch")
mne1 <- mne[myvars]
#mne1$UnderWatch <- mne1$UnderWatch/10
names(mne1) <- c("Day","covid-19", "Testirano")#, "Izolacija / 10")
mne2 <- mne1 %>%
pivot_longer(-Day, names_to = "Legenda", values_to = "count")
p11 <- ggplot(mne2, aes(x=Day, y=count,group = Legenda)) + geom_line(aes(linetype=Legenda)) + geom_point() +
labs(x = "Proslo dana od 09/03/2020 tj prvog dana izvjestavanja o CG", y = "")
#p11 <- ggplot(mne2, aes(x=Day, y=count, col=series)) + geom_line() + geom_point()
ggplotly(p11)
```
### Indeksni/Kontakti slucajevi
```{r,echo=FALSE, warning=FALSE}
library(igraph)
library(sna)
library(GGally)
gra <- read.csv("/Users/Dovla/Desktop/gra.csv")
graC <- read.csv("/Users/Dovla/Desktop/nodCol.csv")
g1 <- graph.data.frame(gra, directed=FALSE)
V(g1)$color <- "red"
V(g1)[gra$e]$color = "green"
#plot(g1, vertex.size = 10, edge.size=0.1, edge.color = "black", lty = 0, arrow.mode=3, arrow.size = 3, main="MNE covid19 clusters 29/03/2020")
#library(visNetwork)
#visIgraph(g1)
g2 <- ggnet2(g1,label = TRUE, label.size = 3, label.color="black",layout.par = list(cell.jitter = 0.75),
shape = as.character(graC$s),
node.color = c(rep("red",22),rep("darkgreen",62)),
legend.size = 5)
ggplotly(g2)
```
Row
-----------------------------------------------------------------------
### Stopa rasta novih COVID-19 slucajeva
```{r}
p2 <- ggplot(data=mne, aes(x=Day, y=InfectionRate1*100, group=1)) + geom_line(linetype = "dashed", colour="red") +
geom_point() +
labs(x = "Proslo dana od 09/03/2020 tj prvog dana izvjestavanja o CG", y = "Stopa u %")
ggplotly(p2)
```
### Novi COVID-19 slucajevi
```{r}
p3 <- ggplot(data=mne, aes(x=Day, y=InfectedNew)) + geom_bar(stat="identity",color="red", fill="white") +
labs(x = "Proslo dana od 09/03/2020 tj prvog dana izvjestavanja o CG", y = "Novih slucajeva")
ggplotly(p3)
```
Mapa svijeta
=======================================================================
**Map**
```{r}
# map tab added by Art Steinmetz
library(leaflet)
library(leafpop)
library(purrr)
library(coronavirus)
load("/Users/Dovla/Downloads/coronavirus.rda")
cv_data_for_plot <- coronavirus %>%
dplyr::filter(cases > 0) %>%
dplyr::group_by(Country.Region,Province.State,Lat,Long,type) %>%
dplyr::summarise(cases = sum(cases)) %>%
dplyr::mutate(log_cases = 2 * log(cases)) %>%
dplyr::ungroup()
cv_data_for_plot.split <- cv_data_for_plot %>% split(cv_data_for_plot$type)
pal <- colorFactor(c("orange", "red","green"), domain = c("confirmed", "death","recovered"))
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]],
lng=~Long, lat=~Lat,
# label=~as.character(cases),
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","cases","Country.Region","Province.State")),
group = df,
# clusterOptions = markerClusterOptions(removeOutsideVisibleBounds = F),
labelOptions = labelOptions(noHide = F,
direction = 'auto'))
})
map_object %>%
addLayersControl(
overlayGroups = names(cv_data_for_plot.split),
options = layersControlOptions(collapsed = FALSE)
)
```
SIR Model - Test
=======================================================================
<iframe style="position: absolute; width :100%; height: 100%; border: none" src="https://praeconium.shinyapps.io/myapp/"></iframe>
About
=======================================================================
I study data, risk and quantiative approaches in various domains including bioinformatics and digital epidemiology. Given current situation it felt natural to visualize and track global/Montenegro statistics, implement basic SIR models, do tweeter analysis and little bit more. Hopefully its not too bad :)
**The Coronavirus Dashboard**
This Coronavirus dashboard provides an overview of the 2019 Novel Coronavirus COVID-19 (2019-nCoV) epidemic. This dashboard is built with R using the Rmakrdown framework and can easily reproduce by others. The code behind the dashboard available [here](https://github.com/0x3w/covid19-mne)
**Data**
The input data for this dashboard is the [Public Health Institute of Montenegro (IJZCG)](https://www.ijzcg.me/me/novosti/azurirani-podaci-o-novom-koronavirusu-2019-ncov) official data.. The data and dashboard is refreshed on a daily bases. The raw data is available [here](https://github.com/0x3W/covid19-me)
**Packages**
* Dashboard interface - the [flexdashboard](https://rmarkdown.rstudio.com/flexdashboard/) package.
* Visualization - the [plotly](https://plot.ly/r/) package for the plots and [leaflet](https://rstudio.github.io/leaflet/) for the map
* Data manipulation - [dplyr](https://dplyr.tidyverse.org/), and [tidyr](https://tidyr.tidyverse.org/)
* Tables - the [DT](https://rstudio.github.io/DT/) package
**Deployment and reproducibly**
The dashboard was deployed to Github docs. If you wish to deploy and/or modify the dashboard on your Github account, you can apply the following steps:
* Fork the dashboard [repository](https://github.com/0x3w/covid19-mne), or
* Clone it and push it to your Github package
* Here some general guidance about deployment of flexdashboard on Github page - [link](https://github.com/pbatey/flexdashboard-example)
For any question or feedback, you can either open an [issue](https://github.com/0x3W/covid19-mne/issues) or contact me on [Twitter](https://twitter.com/praeconium).
**Contribution**
The **Map** tab was contributed by [Art Steinmetz](@adababbage) on this [pull request](https://github.com/RamiKrispin/coronavirus_dashboard/pull/1). Thanks Art!