-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.Rmd
executable file
·293 lines (250 loc) · 8.56 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
---
title: "Teaching schools in England"
author: "Matt Dray"
output:
flexdashboard::flex_dashboard:
theme: paper
source_code: embed
favicon: img/mortar.png
---
```{r setup, include=FALSE}
# packages
library(crosstalk) # inter-widget interactivity
library(dplyr) # data manipulation and pipes (%>%)
library(leaflet) # map widget
library(DT) # datatable widget
# data
# pre-prepared spatial points dataframe
# @data slot is NCTL data with selected GIAS data joined
# @coords slot is latlongs reprojected from eastings/northings in GIAS data
# NCTL: http://apps.nationalcollege.org.uk/s2ssd_new/index.cfm
# GIAS: https://get-information-schools.service.gov.uk/
schools_spdf <- readRDS("output/schools_spdf.RDS")
# tidy up a bit
schools_df <- dplyr::bind_cols(
schools_spdf@data,
as.data.frame(schools_spdf@coords)
) %>%
dplyr::mutate(
num_pupils = as.numeric(num_pupils),
ofsted_rating = forcats::fct_explicit_na(ofsted_rating),
ofsted_rating = forcats::fct_relevel(
ofsted_rating,
c("Outstanding", "Good", "Requires improvement")
)
) %>%
select(
urn,
teaching_school,
region,
local_authority,
alliance_name,
phase.y,
type,
ofsted_rating,
last_ofsted_date,
num_pupils,
latitude,
longitude
)
# create crosstalk shared data object (https://rstudio.github.io/crosstalk/)
sd <- SharedData$new(schools_df)
```
Interactives {data-icon="ion-stats-bars"}
=====================================
Column {data-width=250}
-------------------------------------
### Filters
```{r filters}
# crosstalk filters, sliders, selection
# https://rstudio.github.io/crosstalk/index.html
crosstalk::bscols(
list(
filter_select(
id = "region",
label = "Region",
sharedData = sd,
group = ~region
),
filter_select(
id = "local_authority",
label = "Local authority",
sharedData = sd,
group = ~local_authority
),
filter_select(
id = "alliance",
label = "Alliance",
sharedData = sd,
group = ~alliance_name
),
filter_select(
id = "phase",
label = "Phase",
sharedData = sd,
group = ~phase.y
),
filter_select(
id = "type",
label = "Type",
sharedData = sd,
group = ~type
),
filter_checkbox(
id = "ofsted",
label = "Ofsted rating",
sharedData = sd,
group = ~ofsted_rating,
inline = TRUE,
columns = 2
),
filter_slider(
id = "pupil_count",
label = "Pupil count",
sharedData = sd,
column = ~num_pupils,
step = 10,
round = TRUE,
sep = "",
ticks = FALSE
)
)
)
```
Column {.tabset .tabset-fade data-width=750}
-------------------------------------
### Map
```{r map}
leaflet::leaflet(sd) %>%
leaflet::addProviderTiles(providers$OpenStreetMap) %>%
leaflet::addAwesomeMarkers(
popup = ~paste0( # the popup contains a html table
"<h6>", teaching_school, "</h6>",
"<style>
table, th, td {
padding: 1px;
}
table {
border-spacing: 15px;
}
</style>
<table style='width:100%'>
<tr>
<td>URN</td>
<td>", urn, "</td>
</tr>
<tr>
<td>Region</td>
<td>", region, "</td>
</tr>
<tr>
<td>Local authority</td>
<td>", local_authority, "</td>
</tr>
<tr>
<td>Alliance</td>
<td>", alliance_name, "</td>
</tr>
<tr>
<td>Phase</td>
<td>", phase.y, "</td>
</tr>
<tr>
<td>Type</td>
<td>", type, "</td>
</tr>
<tr>
<td>Pupil count</td>
<td>", num_pupils, "</td>
</tr>
<tr>
<td>Ofsted rating</td>
<td>", ofsted_rating, "</td>
</tr>
</table>"
),
icon = awesomeIcons(
library = "ion",
icon = "ion-record",
iconColor = "white",
markerColor = "blue"
)
) %>%
leaflet::addMeasure()
```
### Datatable
```{r}
# DT package for htmlwidgets datatables
# https://rstudio.github.io/DT/options.html
DT::datatable(
data = sd, # shared data object
#filter = "top", # column filter boxes
extensions = c("Scroller", "Buttons"), # scroll instead of paginate
rownames = FALSE, # remove row names
style = "bootstrap", # style
width = "100%", # full width
class = "compact",
options = list(
deferRender = TRUE,
# scroll
scrollY = 300,
scroller = TRUE,
# button
autoWidth = TRUE, # column width consistent when making selections
dom = "Blfrtip",
buttons =
list(
list(
extend = "collection",
buttons = c("csv", "excel"), # download extension options
text = "Download" # text to display
)
)
),
colnames = c(
"URN" = "urn",
"School" = "teaching_school",
"Region" = "region",
"Local Authority" = "local_authority",
"Alliance" = "alliance_name",
"Phase" = "phase.y",
"Type" = "type",
"Ofsted" = "ofsted_rating",
"Pupil count" = "num_pupils"
)
)
```
Information {data-orientation=rows data-icon="fa-info-circle"}
=====================================
### How to
#### Filters
* The map markers and the data in the table on the 'Interactives' page will automatically update based on your selections from the filter boxes, sliders and checkboxes
* You can select multiple options from within each dropdown list of the filter boxes
* To remove a selection from a dropdown box, click on it and press delete
* Note that the dropdown menus aren't linked (i.e. the local authority dropdown will show *all* options regardless of how many regions are selected)
#### Map tab
* You can select multiple points from the map with the resizable selection tool (button in upper left of map below the zoom buttons), which you can reposition by clicking and dragging the grid icon in it's upper left corner
* Click markers to get a popup with information about that point
* You can measure distances and areas: hover over the button in the upper right of the map, click 'Create new measurement' and add points to the map to start creating a measurement
#### Datatable tab
* You can click rows of the datatable to highlight those markers on the map
* Deselect highlighted rows by clicking them again
### About
#### Disclaimer
* <mark>This was built independently and not on behalf of NCTL</mark>
* Only schools with co-ordinates listed in [Get Information About Schools](https://get-information-schools.service.gov.uk/) could be mapped
* This tool is not a replacement for the official [Teaching schools](http://apps.nationalcollege.org.uk/s2ssd_new/index.cfm) service
#### Teaching schools
The purpose of the [National College for Teaching & Leadership](https://www.gov.uk/government/organisations/national-college-for-teaching-and-leadership) (from their [About us](https://www.gov.uk/government/organisations/national-college-for-teaching-and-leadership/about) page) is 'to improve academic standards by recruiting and developing a workforce to meet the needs of our school system, and to help schools to help each other to improve.' See ['Teaching schools and system leadership: how you can get involved'](https://www.gov.uk/government/collections/teaching-schools-and-system-leadership-how-you-can-get-involved) on GOV.UK.
#### All data are published
* [Teaching schools](http://apps.nationalcollege.org.uk/s2ssd_new/index.cfm) from [NCTL](https://www.gov.uk/government/organisations/national-college-for-teaching-and-leadership)
* [Local authority boundaries](http://geoportal.statistics.gov.uk/datasets/local-authority-districts-december-2017-ultra-generalised-clipped-boundaries-in-united-kingdom-wgs84) from the [ONS Open Geography Portal](http://geoportal.statistics.gov.uk/)
* [Get Information About Schools](https://get-information-schools.service.gov.uk/) from the [Department for Education](https://www.gov.uk/government/organisations/department-for-education)
#### Code
The underlying code is available on [GitHub](https://github.com/matt-dray/nctl-teaching-schools). You can see a preview by clicking the 'Source code' button in the upper right of this page.
#### Tools
* [Leaflet](https://rstudio.github.io/leaflet/) map widget and [DT](https://rstudio.github.io/DT/options.html) table widget
* [Crosstalk](https://rstudio.github.io/crosstalk/) for inter-widget interactivity and selection tools
* [Flexdashboard](https://rmarkdown.rstudio.com/flexdashboard/) for the layout
#### Version details
Version 0.2, generated `r format(Sys.time(), "%d %B %Y")`