-
Notifications
You must be signed in to change notification settings - Fork 0
/
Index.Rmd
305 lines (223 loc) · 13.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
---
title: "Index"
author: "GNtem2"
date: "01/10/2021"
output: html_document
---
```{r setup, warning=F, message=F, echo=F,include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
### Thematic Maps of Children Hospitals in Melbourne
```{r MCH, warning=F,echo=F, message=F}
rm(list=ls())
library(DT)
library(leaflet)
library(stringr)
library(tidyverse)
#
library(readxl)
library(sf)
library(mapview)
library(DT)
```
This is a thematic map of the common childhood presentation to emergency departments (ED). The map is constrained to local government areas within 80 km of the two major children hospitals in Melbourne: Royal Children's Hospital and Monash Children's Hospital. The data comes from Torrens University Australia and can be accessed directly from their website. Data on Australian Early Development Census (AEDC) can also be downloaded from the AEDC website. The shapefiles for the local government areas are available from Australian Bureau of Statistics.
```{r Data, warning=F,message=F, echo=F,results='hide'}
#Pop 2020
X<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "Age_distribution_Persons", skip = 4) %>% mutate(Total4=as.numeric(Number...3),Total5_9=as.numeric(Number...7),Total10_14=as.numeric(Number...11),Total0_14=Total4+Total5_9+Total10_14) %>% select(Code, Total4,Total5_9,Total10_14,Total0_14)
#subset Victoria
X<-X[c(135:215),]
#AEDC 2018
#https://www.aedc.gov.au/researchers
X1<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "Early_childhood_development", skip=4) %>% mutate(Vuln=round(as.numeric(`Children developmentally vulnerable on one or more domains`),1),PerVuln=as.numeric(`% Children developmentally vulnerable on one or more domains`)) %>% select(Code, Vuln,PerVuln)
X1=X1[c(135:215),]
#merge
X1X<-right_join(X1,X,by="Code")
#Socioeconomic disadvantage
XIRSD<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "IRSD", skip=4) %>% mutate(IRSD=round(as.numeric(`Index score (based on Australian score of 1000)`))) %>% select (Code, IRSD)
XIRSD<-XIRSD[c(135:215),]
#merge
XIRSD<-right_join(XIRSD,X1X, by="Code")
#Disability
XDis<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "Disability", skip=4) %>% mutate(Dis_4=round(as.numeric(`Has need for asssistance with core activities, \n0 to 4 years`),1), Dis_5_9=round(as.numeric(`Has need for asssistance with core activities, \n5 to 9 years`),1),Dis_10_14=round(as.numeric(`Has need for asssistance with core activities, \n10 to 14 years`),1),Dis_14=Dis_4+Dis_5_9+Dis_10_14) %>% select(Code, Dis_4, Dis_5_9, Dis_10_14, Dis_14)
XDis<-XDis[c(135:215),]
#merge
XDis<-right_join(XDis,XIRSD, by="Code")
#ED
XED<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "ED_total", skip=4) %>% mutate(ED_Mental=round(as.numeric(`Number...14`),1),ED_Circ=round(as.numeric(`Number...24`),1),ED_Resp=round(as.numeric(`Number...34`),1), ED_Injury=round(as.numeric(`Number...79`),1)) %>% select(Code, ED_Mental, ED_Circ,ED_Resp, ED_Injury)
XED<-XED[c(135:215),]
#merge
XED<-right_join(XED,XDis, by="Code")
#Preventable admission
XPD<-read_xls("./Data/phidu_child_and_youth_data_lga_aust.xls",sheet = "Admissions_prevent_diag_total", skip=4) %>% mutate(PreDiag=round(as.numeric(`Number...4`)))%>% select(Code,PreDiag)
XPD<-XPD[c(135:215),]
#merge
XED<-right_join(XED, XPD, by="Code")
#LGA
LGAsh<-st_read("./Data/LGA_2016_AUST.shp")
#merge
LGAshX<-right_join(LGAsh, XED, by=c("LGA_CODE16"="Code"))
```
```{r Map, warning=F, echo=F,message=F}
#Expected AEDC
LGAshX$Vuln<-round(LGAshX$Vuln,1)
#check for NA
#which(is.na(LGAshX$Vuln))
#which(is.na(LGAshX$ED_Mental))
#which(is.na(LGAshX$ED_Circ))
#which(is.na(LGAshX$ED_Resp))
#replace NA
LGAshX$Vuln<-ifelse(is.na(LGAshX$PerVuln),0,LGAshX$PerVuln)
LGAshX$ED_Mental<-ifelse(is.na(LGAshX$ED_Mental),0,LGAshX$ED_Mental)
LGAshX$ED_Circ<-ifelse(is.na(LGAshX$ED_Circ),0,LGAshX$ED_Circ)
LGAshX$ED_Resp<-ifelse(is.na(LGAshX$ED_Resp),0,LGAshX$ED_Resp)
LGAshX$IRSD<-ifelse(is.na(LGAshX$IRSD),0,LGAshX$IRSD)
LGAshX$Vuln<-ifelse(is.na(LGAshX$Vuln),0,LGAshX$Vuln)
LGAshX$Dis_14<-ifelse(is.na(LGAshX$Dis_14),0,LGAshX$Dis_14)
LGAshX$PreDiag<-ifelse(is.na(LGAshX$PreDiag),0,LGAshX$PreDiag)
#map Victoria
#m<-mapview(LGAshX["ED_Mental"],layer.name="ED Attendance Mental Health")+
#mapview(LGAshX["ED_Circ"],layer.name="ED Attendance Circulatory Disorders")+
#mapview(LGAshX["ED_Resp"],layer.name="ED Attendance Respiratory Disorders")+
#mapview(LGAshX["ED_Injury"],layer.name="ED Attendance Injury")+
#mapview(LGAshX["Dis_14"],layer.name="Disability 0-14 years")+
#mapview(LGAshX["IRSD"],layer.name="Socioeconomic Disadvantage")+
#mapview(LGAshX["Vuln"],layer.name="Vulnerable Children AEDC")
#m
#make html
#mapshot(m, url = paste0(getwd(), "/Victoria_Children.html"))
```
The catchment was created by determining which local government areas are within 80 km of the two major children hospitals. The zoom button (+/-) is in the upper left hand corner. The viewer can also choose the base tile map by clicking on the layer control box, located below the zoom button. The data can also be downloaded directly from the screen by clicking the icons (Copy, CSV, Excel, Print, PDF).
```{r Distance, warning=F,echo=F, message=F}
#Children Hospital
Children_Addresses<-c(Hosp=c("MCH","RCH"),Long=c(145.12070,144.94991), Lat=c(-37.92093,-37.79347))
Children_Addresses<-c(MCH="Monash Children's Hospital, Clayton VIC 3168, Australia", RCH="Royal Children's Hospital, Flemington VIC 3031, Australia")
ChildrenHosp <- tmaptools::geocode_OSM(Children_Addresses, as.sf=TRUE)
ChildrenHosp<-sf::st_transform(ChildrenHosp, sf::st_crs(LGAshX))
#mapview::mapview(ChildrenHosp, map.type="OpenStreetMap.HOT", color='red', col.regions='red', cex=10)
#Distance to Hosp
dist_to_loc <- function (geometry, location){
units::set_units(st_distance(st_centroid (geometry), location)[,1], km)}
#set range at 80 km
dist_range <- units::set_units(80, km)
#LGAshX <- mutate(LGAshX,
# DirectDistanceToMCH= dist_to_loc(geometry,ChildrenHosp["MCH", ]),
# DirectDistanceToRCH= dist_to_loc(geometry,ChildrenHosp["RCH", ]),
# DirectDistanceToNearest = pmin(DirectDistanceToMCH, DirectDistanceToRCH))
#error with function due to NA in row 81
a<-dist_to_loc(LGAshX$geometry,ChildrenHosp["MCH", ])
b<-dist_to_loc(LGAshX$geometry,ChildrenHosp["RCH", ])
c<-pmin(a,b)
LGAshX$DirectDistanceToMCH<-a
LGAshX$DirectDistanceToRCH<-b
LGAshX$DirectDistanceToNearest<-c
LGAshX$MCHcatchment<-ifelse(LGAshX$DirectDistanceToMCH<LGAshX$DirectDistanceToRCH,1,0)
LGAshX$RCHcatchment<-ifelse(LGAshX$DirectDistanceToRCH<LGAshX$DirectDistanceToMCH,1,0)
#apply distance range
LGAChildren <- filter(LGAshX,
DirectDistanceToNearest < dist_range) %>%
mutate(LGA = as.numeric(LGA_CODE16)) %>%
select(-starts_with("LGA_"))
L<-mapview::mapview (LGAChildren["MCHcatchment"], layer.name="Hospital Catchment",zoom=12)+mapview(ChildrenHosp["query"],layer.name="Hospital", legend=F)
mapshot(L,url = paste0(getwd(), "/ChildrenHospital.html"),file="ChildrenHospital.png")
#Vulnerable children
Mental_MCH<-round(sum(LGAChildren$ED_Mental*LGAChildren$MCHcatchment, na.rm = T),0)
Mental_RCH<-round(sum(LGAChildren$ED_Mental*LGAChildren$RCHcatchment, na.rm = T),0)
Circ_MCH<-round(sum(LGAChildren$ED_Circ*LGAChildren$MCHcatchment, na.rm = T),0)
Circ_RCH<-round(sum(LGAChildren$ED_Circ*LGAChildren$RCHcatchment, na.rm = T),0)
Resp_MCH<-round(sum(LGAChildren$ED_Resp*LGAChildren$MCHcatchment, na.rm = T),0)
Resp_RCH<-round(sum(LGAChildren$ED_Resp*LGAChildren$RCHcatchment, na.rm = T),0)
Injury_MCH<-round(sum(LGAChildren$ED_Injury*LGAChildren$MCHcatchment, na.rm = T),0)
Injury_RCH<-round(sum(LGAChildren$ED_Injury*LGAChildren$RCHcatchment, na.rm = T),0)
Dis_MCH<-round(sum(LGAChildren$Dis_14*LGAChildren$MCHcatchment, na.rm = T),0)
Dis_RCH<-round(sum(LGAChildren$Dis_14*LGAChildren$RCHcatchment, na.rm = T),0)
IRSD_MCH<-round(sum(LGAChildren$IRSD*LGAChildren$MCHcatchment, na.rm = T),0)
IRSD_RCH<-round(sum(LGAChildren$IRSD*LGAChildren$RCHcatchment, na.rm = T),0)
Vuln_MCH<-round(sum(LGAChildren$Vuln*LGAChildren$MCHcatchment, na.rm=T ),0)
Vuln_RCH<-round(sum(LGAChildren$Vuln*LGAChildren$RCHcatchment, na.rm = T),0)
PD_MCH<-round(sum(LGAChildren$PreDiag*LGAChildren$MCHcatchment, na.rm=T ),0)
PD_RCH<-round(sum(LGAChildren$PreDiag*LGAChildren$RCHcatchment, na.rm = T),0)
MCH_0_14<-round(sum(LGAChildren$Total0_14*LGAChildren$MCHcatchment, na.rm = T),0)
RCH_0_14<-round(sum(LGAChildren$Total0_14*LGAChildren$RCHcatchment, na.rm = T),0)
library(DT)
DF<-data.frame(Disorder=c("ED Attendance Mental Health","ED Attendance Circulatory Disorders", "ED Attendance Respiratory Disorders","ED Attendance Injury/Poisoning", "Admissions for preventable conditions", "Disability", "Socioeconomic Disadvantage", "developmentally vulnerable on one or more domains - AEDC"),MCH=c(Mental_MCH,Circ_MCH,Resp_MCH,Injury_MCH, PD_MCH, Dis_MCH, IRSD_MCH,Vuln_MCH),`MCH Children 0-14` = c(MCH_0_14,MCH_0_14,MCH_0_14,MCH_0_14,MCH_0_14,MCH_0_14,NA, MCH_0_14),RCH=c(Mental_RCH,Circ_RCH, PD_RCH, Resp_RCH, Injury_RCH, Dis_RCH, IRSD_RCH, Vuln_RCH), `RCH Children 0-14` = c(RCH_0_14,RCH_0_14,RCH_0_14,RCH_0_14,RCH_0_14,RCH_0_14,NA, RCH_0_14))
#enable extensions in data.table
DT_DF<-datatable(DF,extensions = c('Buttons','KeyTable','Responsive'),
options = list(dom='Bfrtip', keys=T, button=c('copy', 'csv', 'excel', 'print', 'pdf')))
saveWidget(DT_DF, "DT_DF.html")
webshot::webshot("DT_DF.html",file="DT_DF.png")
DT_DF
#map Victoria
#n<-mapview(LGAChildren["ED_Mental"],layer.name="ED Attendance Mental Health")+
#mapview(LGAChildren["ED_Circ"],layer.name="ED Attendance Circulatory Disorders")+
#mapview(LGAChildren["ED_Resp"],layer.name="ED Attendance Respiratory Disorders")+
#mapview(LGAChildren["ED_Injury"],layer.name="ED Attendance Injury")+
#mapview(LGAChildren["Dis_14"],layer.name="Disability 0-14 year")+
#mapview(LGAChildren["IRSD"],layer.name="Socioeconomic Disadvantage")+
#mapview(LGAChildren["Vuln"],layer.name="Vulnerable Children AEDC")
#n
```
ED attendance for mental health issues in children (age 0-14).
```{r Mental, warning=F,echo=F,message=F}
n1<-mapview(LGAChildren["ED_Mental"],layer.name="ED Attendance Mental Health",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
#mapshot(n1, url = paste0(getwd(), "/MCH_Mental.html"),file="MCH_Mental.png")
#n1
```
ED attendance for injury/poisoning issues in children (age 0-14).
```{r Injury, warning=F,echo=F,message=F}
n2<-mapview(LGAChildren["ED_Injury"],layer.name="ED Attendance Injury/Poisoning",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(n2, url = paste0(getwd(), "/MCH_injury.html"),file="MCH_injury.png")
#n1
```
ED attendance for Respiratory disorders in children (age 0-14).
```{r Resp, warning=F,echo=F,message=F}
n3<-mapview(LGAChildren["ED_Resp"],layer.name="ED Attendance Respiratory Disorders",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(n3, url = paste0(getwd(), "/MCH_Resp.html"),file="MCH_Resp.png")
```
ED attendance for Circulatory disorders in children (age 0-14).
```{r, Circ, warning=F,echo=F,message=F}
n4<-mapview(LGAChildren["ED_Circ"],layer.name="ED Attendance Circulatory Disorders",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(n4, url = paste0(getwd(), "/MCH_Circ.html"),file="MCH_Circ.png")
```
Preventable admissions in children (age 0-14).
```{r, PD, warning=F,echo=F,message=F}
n5<-mapview(LGAChildren["PreDiag"],layer.name="Preventable admission conditions",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(n5, url = paste0(getwd(), "/MCH_PD.html"),file="MCH_PD.png")
```
Prevalence of disability in children (age 0-14).
```{r Disability, warning=F,echo=F,message=F}
p<-mapview(LGAChildren["Dis_14"],layer.name="Disability 0-14 year",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(p, url = paste0(getwd(), "/MCH_disability.html"),file="MCH_disability.png")
```
Prevalence of Vulnerable children (age 0-14). The term vulnerable refers to Children developmentally vulnerable on one or more domains. These children were assessed in their Australian Early Development Census (AEDC) first year at school.
```{r Vulnerable, warning=F,echo=F,message=F}
q<-mapview(LGAChildren["Vuln"],layer.name="Vulnerable Children AEDC",col.regions=c("blue","green","red"))+mapview(ChildrenHosp["query"],layer.name="Hospital",legend=F)
mapshot(q, url = paste0(getwd(), "/MCH_AEDC.html"),file = "MCH_AEDC.png")
```
```{r resize image, echo=F, warning=F, message=F}
library(magick)
a<-image_read("MCH_Mental.png")
a1<-image_resize(a,"x400")
image_write(a1,path = "MCH_Mental2.png",format="png")
b<-image_read("MCH_Resp.png")
b1<-image_resize(b,"x400")
image_write(a1,path = "MCH_Resp2.png",format="png")
d<-image_read("MCH_Circ.png")
d1<-image_resize(d,"x400")
image_write(d1,path = "MCH_Circ2.png",format="png")
e<-image_read("MCH_PD.png")
e1<-image_resize(e,"x400")
image_write(e1,path = "MCH_PD2.png",format="png")
f<-image_read("MCH_disability.png")
f1<-image_resize(f,"x400")
image_write(f1,path = "MCH_disability2.png",format="png")
g<-image_read("MCH_injury.png")
g1<-image_resize(g,"x400")
image_write(g1,path = "MCH_injury2.png",format="png")
h<-image_read("MCH_AEDC.png")
h1<-image_resize(h,"x400")
image_write(h1,path = "MCH_AEDC2.png",format="png")
i<-image_read("ChildrenHospital.png")
i1<-image_resize(i,"x400")
image_write(i1,path = "ChildrenHospital2.png",format="png")
```
Note that the `echo = FALSE` parameter was added to the code chunk to prevent printing of the R code that generated the plot.