-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtest_Covid_Exposure_ACT.Rmd
167 lines (120 loc) · 5.03 KB
/
test_Covid_Exposure_ACT.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
---
title: "Covid19 exposure locations in the ACT"
resource_files:
- data/last.csv
#runtime: shiny
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
params:
lup: "unknown"
---
<style>
.crosstalk-input-checkboxgroup{
color: blue;
font-size: 12px;
}
</style>
```{r setup, include=TRUE}
library(tidyverse)
library(ggmap)
library(leaflet)
library(plotly)
library(flexdashboard)
library(DT)
library(rgdal)
library(crosstalk)
#latest dataset
tab3 <- read.csv("data/last.csv")
# Aggregate method
cols <- c( "yellow", "red","cyan", "blue")
addBuses <- TRUE
cc <- as.numeric(factor(tab3$Contact))
labs <- paste(tab3$Contact, tab3$Status,tab3$Exposure.Location, tab3$Street, tab3$Suburb, tab3$Date,tab3$Arrival.Time, tab3$Departure.Time, tab3$doubles, sep="<br/>")
###############################################
##plot the map
#tab3$dd<-as.numeric(as.Date(tab3$Date, format = "%d/%m/%Y"))
df_shared <- crosstalk::SharedData$new(tab3[,c(1,8,2:7)])
m <- leaflet(df_shared) %>% addTiles()
if (addBuses) {
#read from shape file
busses <- readOGR(dsn = "c:/bernd/r/covid_canberra/bus", layer = "geo_export_69c76e06-1d3f-4619-be3b-b4e5789be8ca", verbose = FALSE )
#search all bus lines that are mentioned
bindex <- grep("Bus Route", tab3$Exposure.Location)
buslanes <- tab3$Exposure.Location[bindex]
busnumbers <- gsub("Bus Route ([0-9,A-Z]+) Transport.*","\\1", buslanes)
blineindex <- which(busses$short_name %in% busnumbers)
blabs <- paste(paste0("Bus route: ", busses$short_name[blineindex]),"<strong> For bus stops and ","exposure times, please"," search the table." , sep="<br/>")
bb <- (busses[blineindex,])
coo <- coordinates(bb)
bcols <- colorRampPalette(c("purple", "green"))( length(coo))
for (ib in 1:length(coo))
{
cood <- data.frame(coo[[ib]])
m <- m %>% addPolylines(lng=cood[,1], lat=cood[,2], color = bcols[ib], weight = 3, opacity = 0.4, popup = blabs[ib])
}
}
m <- m %>% addCircleMarkers(lat=tab3$lat, lng=tab3$lon,popup = labs, weight=0.5, color = cols[cc], radius = 5 , fillOpacity = 0.8)#,
# clusterOptions =markerClusterOptions(spiderfyDistanceMultiplier=1.5,
# iconCreateFunction=JS("function (cluster) {
#
# var childCount = cluster.getChildCount();
#
# if (childCount < 100) {
# c = 'rgba(64, 64, 64, 0.5);'
# } else if (childCount < 1000) {
# c = 'rgba(64, 64, 64, 0.5);'
# } else {
# c = 'rgba(64, 64, 64, 0.5);'
# }
# return new L.DivIcon({ html: '<div style=\"background-color:'+c+'\"><span>' + childCount + '</span></div>', className: 'marker-cluster', iconSize: new L.Point(40, 40) });
# }")) )
m <- m %>% addLegend("bottomright", labels = levels(factor(tab3$Contact)), colors = cols, opacity = 1)
####################################################
### add bus lines mentioned
```
```{r title, results='asis'}
cat(paste0("# ", params$lup))
```
<sup>Disclaimer: This map shows the covid exposure locations in the ACT and is an **unofficial website** based on [official sources](https://www.covid19.act.gov.au/act-status-and-response/act-covid-19-exposure-locations). So if in doubt, refer to the [offical website](https://www.covid19.act.gov.au/act-status-and-response/act-covid-19-exposure-locations), which has now also an [**official map**](https://www.covid19.act.gov.au/act-status-and-response/act-covid-19-exposure-locations/map#Map-of-ACT-exposure-locations) included. Supported by Volunteers from the University of Canberra. Contacts: Bernd Gruber [[email protected]] & Anthony Davidson [[email protected]]</sup>
Column {data-width=450}
-----------------------------------------------------------------------
### Map of Exposure sites and exposed bus routes
```{r}
#checks
m
```
Column {data-width=350}
-----------------------------------------------------------------------
### Table of Exposure sites
```{r}
bscols(
filter_checkbox(
id = "contact",
label = "",
sharedData = df_shared,
group = ~Contact,
inline=TRUE
)
)
bscols( filter_select(id="dates", label="Date",sharedData = df_shared, group=~Date))
#bscols( filter_slider(id="lat", label="lat",sharedData = df_shared, column=~as.numeric(substr(tab3$Arrival.Time,1,2 ))))
dtt <-DT::datatable(df_shared,
caption = 'Search for entries, (shift)click to select, this highlights the locations in the map.',selection = "multiple", rownames = FALSE,
extensions = c("Buttons", "Select"),options = list(pageLength = 50, ausoHideNavigation=TRUE,
dom = 'Bfrtip',
select = TRUE,
buttons = list(
"copy",
list(
extend = "selectNone",
text = "Clear"
)
),
initComplete = JS(
"function(settings, json) {",
"$(this.api().table().header()).css({'font-size': '50%'});",
"}"))) %>% DT::formatStyle(columns = 1:8, fontSize='70%')
dtt
```