-
Notifications
You must be signed in to change notification settings - Fork 1
/
cop-dashboard.Rmd
641 lines (514 loc) · 18.8 KB
/
cop-dashboard.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
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
---
title: "Data Science Community of Practice"
output:
flexdashboard::flex_dashboard:
orientation: rows
vertical_layout: scroll
source_code: https://github.com/bcgov/bcgov-data-science-cop
---
<!--
Copyright 2020 Province of British Columbia
This work is licensed under the Creative Commons Attribution 4.0 International License.
To view a copy of this license, visit http://creativecommons.org/licenses/by/4.0/.
-->
```{r setup, include=FALSE}
## libraries
library(flexdashboard)
library(readr)
library(janitor)
library(lubridate)
library(dplyr)
library(tidyr)
library(ggplot2)
library(waffle) #dev version remotes::install_github("hrbrmstr/waffle")
library(RColorBrewer)
library(plotly)
library(safepaths) ## https://github.com/bcgov/safepaths
library(reactable)
library(htmltools)
library(crosstalk)
library(flextable)
library(treemap)
## load data
event_participation <-
read_csv(use_network_path("7. Data Science CoP/data/cop-data-events.csv"),
col_types = c("ccddDccdc")) %>%
clean_names()
participation_by_ministry <-
read_csv(use_network_path("7. Data Science CoP/data/cop-data-part-ministries.csv"),
col_types = c("cDdcc")) %>%
clean_names()
workshop_feedback <- read_csv(use_network_path("7. Data Science CoP/data/cop-training-survey-feedback.csv"),
col_types = c("ccdDccddddddddddddcc")) %>%
clean_names()
org_acronyms <- read_csv(use_network_path("7. Data Science CoP/data/ministry-name-abbrevation.csv"),
col_types = c("cc")) %>%
clean_names()
```
Event Participation
======================================================================
Row
-----------------------------------------------------------------------
### Number of Events (All Time) {.value-box}
```{r}
#number of cop events
valueBox(value = event_participation %>%
count(), icon = "fa-calendar")
```
### Total Attendance (All Time) {.value-box}
```{r}
#cumulative event attendance
participation_count <- event_participation %>%
filter(date < today()) %>%
select(date, event_title, event_type, in_person_participants, on_line_participants) %>%
mutate(on_line_participants = replace_na(on_line_participants, 0),
in_person_participants = replace_na(in_person_participants, 0),
participants = in_person_participants + on_line_participants)
valueBox(value = participation_count %>%
summarise(sum(participants)), icon = "fa-users")
```
### Geographic Locations {.value-box}
```{r}
#number of locations
num_locations <- event_participation %>%
distinct(location) %>%
filter(location != "remote") %>%
count()
valueBox(value = num_locations, icon = "fa-globe")
```
### Number of Ministries & Organizations Represented (All Time) {.value-box}
```{r}
#number of ministries
valueBox(value = participation_by_ministry %>%
filter(!ministry %in% c("Unknown", "External")) %>%
distinct(ministry) %>%
count(), icon = "fa-building")
```
Row
-----------------------------------------------------------------------
### Number of Events by Year
```{r}
#number of events by year and event type
event_sum <- participation_count %>%
mutate(year = year(date)) %>%
mutate(event_type = recode(event_type, social = "meet-up")) %>%
group_by(year, event_type) %>%
count()
#event colours
event_colours = c("meet-up" = "#1f78b4",
"webinar" = "#ff7f00",
"workshop" = "#33a02c")
#event bar chart theme
theme_bar <- theme(
panel.grid.major.x = element_blank(),
panel.grid.minor.x = element_blank(),
axis.line = element_line(),
axis.text = element_text(size = 11),
legend.position = "top",
legend.direction = "horizontal",
legend.text = element_text(size = 11))
#bar chart of number of events
ggplot(data = event_sum, aes(year, n)) +
geom_col(aes(fill = event_type), alpha = 0.6) +
labs(
x = NULL,
y = NULL
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 22),
breaks = seq(0, 22, 4)) +
scale_fill_manual(name = NULL,
values = event_colours) +
theme_minimal() +
theme_bar
```
### Locations of In-Person Events
```{r}
#get cities from bcmaps
cities <- bcmaps::bc_cities(class = "sf") %>%
filter(NAME %in% c("Vancouver", "Victoria", "Prince George"))
#join cities to event data
event_locations <- event_participation %>%
select(location) %>%
group_by(location) %>%
count() %>%
ungroup() %>%
left_join(cities, by = c("location" = "NAME")) %>%
# mutate(location = recode(location, "Prince George" = "Prince\nGeorge")) %>%
sf::st_as_sf()
#plot in-person event locations
event_locations %>%
filter(location != "remote") %>%
ggplot() +
geom_sf(data = bcmaps::bc_bound(class = "sf"), fill = "white") +
geom_sf(colour = "#33a02c", size = 3) +
geom_sf_text(aes(label = location),
vjust = 1.8, hjust = -.01,
size = 3.5, colour = "grey40") +
# coord_sf(datum = NA) +
labs(x = NULL, y = NULL) +
theme_minimal() +
theme(legend.position = "none")
```
Row
-----------------------------------------------------------------------
### Event Attendance by Year
```{r}
#participation by year and event
participation_sum <- participation_count %>%
mutate(year = year(date)) %>%
mutate(event_type = recode(event_type, social = "meet-up")) %>%
group_by(year, event_type) %>%
summarise(total_part = sum(participants),
total_event = length(event_type))
#bar chart of number of participants
ggplot(data = participation_sum, aes(year, total_part)) +
geom_col(aes(fill = event_type), alpha = 0.6) +
labs(
x = NULL,
y = NULL
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 600),
breaks = seq(0, 600, 100)) +
scale_fill_manual(name = NULL,
values = event_colours) +
theme_minimal() +
theme_bar
```
### Attendance by Ministry or Organization
```{r}
#waffle colour palette
# colour_count_waffle <- length(unique(participation_by_ministry$ministry))
# get_palette_waffle <- colorRampPalette(brewer.pal(12, "Paired"))
#waffle plot
# participation_by_ministry %>%
# left_join(org_acronyms, by = "ministry") %>%
# filter(!ministry %in% c("Unknown", "External")) %>%
# # mutate(ministry = stringr::str_wrap(ministry, 45)) %>%
# group_by(abbreviation) %>%
# summarise(count = sum(number_participants)) %>%
# ggplot(aes(fill = abbreviation, values = count)) +
# geom_waffle(rows = 10) +
# scale_fill_manual(values = get_palette_waffle(colour_count_waffle),
# name = NULL) +
# coord_equal() +
# theme_enhance_waffle() +
# theme_void() +
# theme(
# legend.position = "bottom",
# legend.text = element_text(size = 8)) +
# guides(fill = guide_legend(nrow = 6))
#treemap
df <- participation_by_ministry %>%
left_join(org_acronyms, by = "ministry") %>%
filter(!ministry %in% c("Unknown", "External")) %>%
group_by(abbreviation) %>%
summarise(count = sum(number_participants))
treemap(
df,
index = "abbreviation",
vSize = "count",
type = "index",
fontsize.labels = 8,
force.print.labels = TRUE,
fontface.labels = "plain",
border.lwds = .5,
title = "",
palette = brewer.pal(12, "Paired")
)
```
Training Events
======================================================================
Row
-----------------------------------------------------------------------
### Number of Training Events (Total All Time) {.value-box}
```{r}
# number of workshops + webinars delivered all time
valueBox(value = event_participation %>%
filter(event_type %in% c("workshop", "webinar")) %>%
count(), icon = "fa-calendar")
```
### Number of Training Attendees (Total All Time) {.value-box}
```{r}
#number of workshop+webinars attendees all time
valueBox(value = participation_count %>%
filter(event_type %in% c("workshop", "webinar")) %>%
summarise(sum(participants)), icon = "fa-users")
```
Row
-----------------------------------------------------------------------
### Workshops (Total All Time) {.value-box}
```{r}
# number of workshops delivered all time
valueBox(value = event_participation %>%
filter(event_type == "workshop") %>%
count(), icon = "fa-building")
```
### Webinars (Total All Time) {.value-box}
```{r}
# number of webinars delivered all time
valueBox(value = event_participation %>%
filter(event_type == "webinar") %>%
count(), icon = "fa-video")
```
### Workshop Training Attendees (Total All Time) {.value-box}
```{r}
#number of workshop attendees all time
valueBox(value = participation_count %>%
filter(event_type == "workshop") %>%
summarise(sum(participants)), icon = "fa-user")
```
### Webinar Training Attendees (Total All Time) {.value-box}
```{r}
#number of webinar attendees all time
valueBox(value = participation_count %>%
filter(event_type == "webinar") %>%
summarise(sum(participants)), icon = "fa-user")
```
Row
-----------------------------------------------------------------------
### Number of Training Events by Year
```{r}
#number of events by year and event type
training_sum <- participation_count %>%
mutate(year = year(date)) %>%
filter(event_type %in% c("workshop", "webinar")) %>%
group_by(year, event_type) %>%
count()
#training event colours
training_colours = c("webinar" = "#ff7f00",
"workshop" = "#33a02c")
#bar chart of number of events
ggplot(data = training_sum, aes(year, n)) +
geom_col(aes(fill = event_type), alpha = 0.6) +
labs(
x = NULL,
y = NULL
) +
scale_y_continuous(expand = c(0, 0),
limits = c(0, 12),
breaks = seq(0, 12, 2)) +
scale_fill_manual(name = NULL,
values = training_colours) +
theme_minimal() +
theme_bar
```
### Training Attendance by Event (Number Offerings)
```{r}
#event horizontal bar chart theme
theme_bar_horiz <- theme(
panel.grid.major.y = element_blank(),
panel.grid.minor.y = element_blank(),
panel.grid.minor.x = element_blank(),
axis.line = element_line(),
axis.text = element_text(size = 11),
legend.position = "top",
legend.direction = "horizontal",
legend.text = element_text(size = 11))
#number participants by topic
participation_count %>%
filter(event_type %in% c("workshop", "webinar")) %>%
mutate(event_title2 = case_when(event_type == "webinar" ~ "data-science-cop-webinar",
TRUE ~ event_title)) %>%
group_by(event_title2, event_type) %>%
summarise(total_trained = sum(participants),
no_times_offered = n()) %>%
ggplot(aes(total_trained, reorder(event_title2, -total_trained))) +
geom_col(aes(fill = event_type), alpha = 0.6) +
scale_fill_manual(name = NULL,
values = training_colours) +
geom_text(aes(label = paste0("(", no_times_offered, ")")),
nudge_x = 50, colour = "grey30", size = 4) +
labs(x = NULL, y = NULL) +
scale_x_continuous(expand = c(0, 0),
limits = c(0, 950),
breaks = seq(0, 900, 150)) +
theme_minimal() +
theme_bar_horiz
```
Row
-----------------------------------------------------------------------
### Workshop Evaluation: Rating of Excellent + Very Good (Avg All Workshops)
```{r}
#percent excellent + very good overall assessment scores (averaged across workshops)
metric_overall <- workshop_feedback %>%
mutate(metric = overall_assessment_excellent_percent + overall_assessment_very_good_percent) %>%
select(metric) %>%
summarise(percent = mean(metric, na.rm =TRUE)) %>%
mutate(percent = paste0(percent, "%")) %>%
pull()
gauge(metric_overall, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
# valueBox(value = metric_overall, icon = "fa-comments",
# caption = "Excellent or Very Good Overall Rating (All Workshops)")
```
### Workshop Organization Evaluation: Rating of Excellent + Very Good (Avg All Workshops)
```{r}
#percent excellent + very good organisation assessment scores (averaged across workshops)
metric_organization <- workshop_feedback %>%
mutate(metric = organization_assessment_excellent_percent + organization_assessment_very_good_percent) %>%
select(metric) %>%
summarise(percent = mean(metric, na.rm =TRUE)) %>%
mutate(percent = paste0(percent, "%")) %>%
pull()
gauge(metric_organization, min = 0, max = 100, symbol = '%', gaugeSectors(
success = c(80, 100), warning = c(40, 79), danger = c(0, 39)
))
# valueBox(value = metric_organization, icon = "fa-commenting-o",
# caption = "Excellent or Very Good Organization Rating (All Workshops)")
```
Row
-----------------------------------------------------------------------
### Workshop Participant Assessments: Overall Rating by Workshop
```{r}
tidy_feedback <- workshop_feedback %>%
pivot_longer(cols = starts_with(c("overall", "organization")),
names_to = "category",
values_to = "percent") %>%
select(event_title, category, percent) %>%
mutate(cat_label = stringr::str_remove_all(category, "(overall|organization)_assessment_"),
cat_label = stringr::str_remove(cat_label, "_percent"),
cat_label = stringr::str_replace(cat_label, "_", " "),
cat_label = factor(cat_label, levels = c("excellent",
"very good",
"good",
"fair",
"poor")))
#colour palette
colour_count <- length(unique(tidy_feedback$cat_label))
get_palette <- colorRampPalette(brewer.pal(9, "YlGn")[2:9])
# colour_palette <- c("poor" = "pink",
# "fair" = "red",
# "good" = "green",
# "very good" = "blue",
# "excellent" = "black")
p <- tidy_feedback %>%
drop_na() %>%
filter(stringr::str_starts(category, "overall")) %>%
group_by(event_title, cat_label) %>%
summarise(avg_percent = mean(percent)) %>%
ggplot(aes(avg_percent, event_title, fill = cat_label)) +
geom_col(alpha = 0.6) +
scale_x_continuous(expand = c(0, 0),
limits = c(0, 110),
breaks = seq(0, 100, 20)) +
scale_fill_manual(values = rev(get_palette(colour_count)),
name = NULL,
guide = guide_legend(reverse = TRUE),
na.value = "black") +
labs(x = NULL, y = NULL) +
theme_minimal() +
theme_bar_horiz +
theme(legend.position = "right",
legend.direction = "vertical")
p
# ggplotly(p)
```
### Workshop Participant Assessments: Organization Rating by Workshop
```{r}
tidy_feedback %>%
drop_na() %>%
filter(stringr::str_starts(category, "organization")) %>%
group_by(event_title, cat_label) %>%
summarise(avg_percent = mean(percent)) %>%
ggplot(aes(avg_percent, event_title, fill = cat_label)) +
geom_col(alpha = 0.6) +
scale_x_continuous(expand = c(0, 0),
limits = c(0, 110),
breaks = seq(0, 100, 20)) +
scale_fill_manual(values = rev(get_palette(colour_count)),
name = NULL,
guide = guide_legend(reverse = TRUE),
na.value = "black") +
labs(x = NULL, y = NULL) +
theme_minimal() +
theme_bar_horiz +
theme(legend.position = "right",
legend.direction = "vertical")
```
Explore Event Data
======================================================================
Row {data-height="900"}
-----------------------------------------------------------------------
```{r}
event_num_min <- participation_by_ministry %>%
select(event_title, date, ministry) %>%
distinct() %>%
group_by(date, event_title) %>%
count()
table_df <- participation_count %>%
left_join(event_num_min, by = c("event_title", "date")) %>%
select(event_type, event_title, date, n, participants) %>%
arrange(desc(date))
data <- SharedData$new(table_df)
bscols(
widths = c(4,8),
list(
filter_checkbox("type", "Event Type", data, ~event_type),
filter_slider("part", "Number of Participants", data, ~participants, width = "100%")
),
reactable(data,
columns = list(
event_type = colDef(name = "Event Type" #,
# footer = "Total"
),
date = colDef(name = "Date", format = colFormat(date = TRUE, locales = "en-GB")),
event_title = colDef(name = "Event"),
participants = colDef(name = "Number of Participants",
align = "center" #,
# footer = function(values) sum(values)
),
n = colDef(name = "Number of Ministries/Organizations",
align = "center",
na = "NA")),
# defaultColDef = colDef(footerStyle = list(fontWeight = "bold")),
# filterable = TRUE,
width = 700,
height = "100%",
# pagination = FALSE,
showPageSizeOptions = TRUE,
# pageSizeOptions = c(10, 20, 50),
defaultPageSize = 10,
minRows = 10,
highlight = TRUE,
striped = TRUE)
)
```
```{r, include=FALSE, eval=FALSE}
library(officer)
border_format <- fp_border(color = "gray30", width = 2)
ft_table <- table_df %>%
flextable() %>%
set_header_labels(
event_type = "Event Type",
date = "Date",
event_title = "Event",
participants = "Number of Participants",
n = "Number Ministries Represented"
) %>%
set_table_properties(width = .7, layout = "autofit") %>%
theme_zebra(odd_header = "transparent", even_header = "transparent") %>%
align(align = "left", part = "header") %>%
align(align = "left", part = "body") %>%
hline_bottom(part = "header", border = border_format) %>%
hline_top(part = "header", border = border_format) %>%
hline_bottom(part = "all", border = border_format)
ft_table
```
About
======================================================================
Row {data-height=75}
-----------------------------------------------------------------------
The **Data Science Community of Practice (CoP)** was launched in August 2018 as a venue for data science enthusiasts across the B.C. government to connect, communicate, share and learn about data science. The community exists online—and sometimes in-person—with a focus on sharing practices, inspiring each other and supporting continuous learning in data science in the BC Public Service.
Row {data-height=200}
-----------------------------------------------------------------------
```{r, fig.width=3, fig.height=3}
knitr::include_graphics(use_network_path("7. Data Science CoP/CoP-logo-sticker/cop-logo-updated.png"))
```
Row {data-height=100}
-----------------------------------------------------------------------
• **Join** the bcgov Data Science Community of Practice online in bcgov Yammer and MS Teams
• **Read** blog posts about past & future bcgov Data Science Community of Practice events on @Work
• **Find** bcgov Data Science Community of Practice materials & resources on [bcgov GitHub](https://github.com/bcgov/bcgov-data-science-cop)