-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
921 lines (823 loc) · 40 KB
/
app.R
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
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
# Packages ----------------------------------------------------
library(shiny)
library(shinydashboard)
library(tidyverse)
library(janitor)
library(grid)
library(udpipe)
library(wordcloud)
library(bsicons)
library(htmltools)
library(fontawesome)
library(DT)
library(googlesheets4)
gs4_deauth()
# Time interval
time_interval <- 604800000
# Everyone, Leadership, new to data science, software developers
cbPalette <- c("#E69F02", "#56B4E9", "#009E73", "#008080")
#Leadership, new to data, software developers
cbLEPalette <-c("#56B4E9", "#009E73", "#008080", "#440154")
xlabel_view <- c(rep(c("black", "transparent", "transparent", "transparent"), 41), "black", "transparent") #166 rows
#cc <- rev(c("#fde725", "#addc30", "#5ec962", "#28ae80", "#21918c", "#2c728e", "#3b528b", "#472d7b", "#440154"))
viridis_cc <- c("#440154", "#2c728e", "#fde725", "#28ae80", "#addc30")
# Wordcloud
ud_model <- udpipe::udpipe_load_model("wordcloud-model.udpipe")
# Functions
coacross <- function(...) {
coalesce(!!!across(...))
}
get_to_bind <- function(inputdf, prepost, workshopOI){
nrankOI <- nrow(inputdf %>%
filter(pre_post == prepost & workshop == workshopOI) %>% drop_na())
return(inputdf %>%
filter(pre_post == prepost & workshop == workshopOI) %>%
select(value) %>% `colnames<-`(c(paste(workshopOI,prepost, sep="-"))) %>%
colSums(na.rm = TRUE) %>%
as.data.frame() %>% `colnames<-`(c("totalRank")) %>%
mutate(avgRank = totalRank / nrankOI))
}
ui <- dashboardPage(
# Dashboard Header ----------------------------------------------------
dashboardHeader(
title = "ITN Dashboard"
),
# Dashboard Sidebar ----------------------------------------------------
dashboardSidebar(
sidebarMenu(
menuItem("Courses", tabName = "tab_courses", icon = icon("chalkboard"),
menuSubItem("Plots", tabName = "tab_courses_plots"),
menuSubItem("Tables", tabName = "tab_courses_tables")),
menuItem("Workshops", tabName = "tab_workshops", icon = icon("people-group")),
menuItem("Software Usage", tabName = "tab_software_usage", icon = icon("robot")),
menuItem("Collaborations", tabName = "tab_collabs", icon = icon("people-arrows")),
menuItem("About", tabName = "tab_about", icon = icon("info"))
)
),
# Dashboard Body ----------------------------------------------------
dashboardBody(
# Custom style
includeCSS("www/style.css"),
# Favicon
tags$head(tags$link(rel="shortcut icon", href="i/img/favicon.ico")),
tabItems(
# Courses Tab ----------------------------------------------------
tabItem(tabName = "tab_courses_plots",
# First row
fluidRow(
box(title = "Visitors across Educational Resources",
plotOutput("plot_visitor_website")),
box(title = "Engagement by Modality",
selectInput("modality", "Modality:",
c("Website" = "website",
"Leanpub" = "leanpub",
"Coursera" = "coursera")),
plotOutput("plot_engagement_modality"))
),
# Second row
fluidRow(
box(title = "Website Engagement",
selectInput("metric", "Metric:",
c("Screen Page Views per User" = "screen_page_views_per_user",
"Average Session Duration" = "average_session_duration",
"Event Count per User" = "event_count_per_user",
"Engagement Rate" = "engagement_rate")),
plotOutput("plot_engagement_website")),
box(title = "Course Engagement by Target Audience",
plotOutput("plot_engagement_target"))
),
# Third row
fluidRow(
box(title = "Total Number of Learners for each Course",
plotOutput("plot_learner_course")),
box(title = "Number of Coursera Enrollments by Course",
plotOutput("plot_coursera"),
footer = "*Data was manually updated, and may be outdated.")
),
# Fourth row
fluidRow(
box(title = "Number of Leanpub Enrollments by Course",
plotOutput("plot_leanpub"),
footer = "*Data was manually updated, and may be outdated."),
box(title = "Course Popularity over Time",
plotOutput("plot_learner_launch_date"))
)
),
# Tables Tab ----------------------------------------------------
tabItem(tabName = "tab_courses_tables",
tabBox(side = "left",
height = "400px",
tabPanel("User Totals",
DTOutput("table_user_total")),
tabPanel("User Engagement",
DTOutput("table_user_engagement")),
width = 12
)
),
# Workshops Tab ----------------------------------------------------
tabItem(tabName = "tab_workshops",
# First Row
fluidRow(
box(title = "Workshop Recommendation Likelihood",
plotOutput("plot_workshop_recommendation"),
footer = textOutput("percent_rec")),
box(title = "Workshop Relevance",
plotOutput("plot_workshop_relevance"))
),
# Second Row
fluidRow(
box(title = "Change in confidence on workshop topic(s)",
plotOutput("plot_workshop_confidence_pooled")),
box(title = "Change in confidence for specific workshops",
plotOutput("plot_workshop_confidence"))
),
# Third Row
fluidRow(
box(title = "Workshop Registrant Career Stage",
width = 12,
plotOutput("plot_workshop_career_stage"))
),
# Second Row
fluidRow(
box(title = "Workshop Review: What Did You Like Most?",
plotOutput("plot_workshop_review")),
box(title = "Workshop Recommendations for Improvement",
plotOutput("plot_workshop_improvement"))
)
),
# Software Usage Tab ----------------------------------------------------
tabItem(tabName = "tab_software_usage",
# First Row
fluidRow(
infoBox("Loqui",
"A Shiny app for Creating Automated Videos",
href = "https://loqui.fredhutch.org/",
icon = icon("video")),
infoBox("Number of Loqui Users", 20, icon = icon("user-group")),
infoBox("Number of Videos made with Loqui", 490, icon = icon("play"))
),
# Second Row
fluidRow(
box(title = "Monthly CRAN Downloads",
width = 12,
plotOutput("plot_monthly_cran_download"),
footer = "*Dashed vertical lines denote when software was published on CRAN.")
),
# Third Row
fluidRow(
tabBox(side = "left",
height = "300px",
tabPanel("Package Download Totals",
DTOutput("table_cran_downloads")),
tabPanel("Package Download Totals - Last 6 months",
DTOutput("table_cran_sixmonths")),
width = 8
)
)
),
# Collaborations Tab ----------------------------------------------------
tabItem(tabName = "tab_collabs",
# First Row
fluidRow(
box(title = "All Collaborations",
plotOutput("plot_collaboration_all")),
box(title = "ITCR-Only Collaborations",
plotOutput("plot_collaboration_itcr"))
),
#Second Row
fluidRow(
box(title = "All Collaborations: Specifying Affiliation",
plotOutput("plot_collaboration_all_color"))
)
),
# About Tab ----------------------------------------------------
tabItem(tabName = "tab_about",
"UNDER CONSTRUCTION"
)
)
)
)
# Server ----------------------------------------------------
server <- function(input, output) {
# Data: ITCR Course ----------------------------------------------------
itcr_course_data_raw <- reactiveFileReader(time_interval,
NULL,
"https://raw.githubusercontent.com/FredHutch/itn-dashboard/main/data/itcr_course_metrics.csv",
readr::read_csv)
itcr_course_data <- reactive({
itcr_course_data <- itcr_course_data_raw() %>%
mutate(target_audience = replace_na(target_audience, "Everyone"))
itcr_course_data$webAndEnrollmentTotals <- itcr_course_data %>%
select(website_count, coursera_count, leanpub_count) %>%
rowSums(na.rm = TRUE)
itcr_course_data
})
itcr_course_data_long <- reactive({
itcr_course_data() %>%
select(c("website",
"totalUsers",
"coursera_count",
"leanpub_count",
"target_audience")) %>%
tidyr::pivot_longer(!c(website, target_audience),
names_to = "modality",
values_to = "learner_count") %>%
filter(!(website %in% c("ITN Website", "OTTR website", "metricminer.org"))) %>%
mutate(modality = case_when(
modality == "leanpub_count" ~ "Total Leanpub Enrollments",
modality == "coursera_count" ~ "Total Coursera Enrollments",
modality == "totalUsers" ~ "Website Learners",
TRUE ~ modality
))
})
# Data: ITCR Google Analytics ----------------------------------------------------
ga_metrics <- reactiveFileReader(time_interval,
NULL,
"https://raw.githubusercontent.com/FredHutch/itn-dashboard/main/data/itcr_ga_metric_data.csv",
readr::read_csv)
user_totals <- reactive({
ga_metrics() %>%
clean_names() %>%
select(website, active_users, average_session_duration) %>%
mutate(average_session_duration = round(average_session_duration, digits = 0))
})
user_engagement <- reactive({
ga_metrics() %>%
clean_names() %>%
select(website, screen_page_views_per_user,
sessions, screen_page_views, engagement_rate) %>%
mutate(screen_page_views_per_user = round(screen_page_views_per_user, 0),
engagement_rate = round(engagement_rate, 2))
})
# Data: Course Engagement by Modality ----------------------------------------------------
course_raw <- reactiveFileReader(time_interval,
NULL,
"https://docs.google.com/spreadsheets/d/1-8vox2LzkVKzhmSFXCWjwt3jFtK-wHibRAq2fqbxEyo/edit?usp=sharing",
googlesheets4::read_sheet,
sheet = "Course_data")
course_processed <- reactive({
course_raw() %>%
pivot_longer(cols = contains("count"), names_to = "modality", values_to = "number_of_learners") %>%
mutate(course_name = factor(website)) %>%
separate(modality, sep = "_", into = c("modality", "meh")) %>%
mutate(modality = factor(modality, levels = c("website", "leanpub", "coursera"),
labels = c("website", "leanpub", "coursera"))) %>%
mutate(course_order = case_when(target_audience == "Leadership" ~ 1,
target_audience == "New to data" ~ 2,
target_audience == "Software developers" ~ 3)) %>%
rename("Target Audience" = target_audience) %>%
filter(modality == input$modality)
})
# Data: ITCR Slido ----------------------------------------------------
itcr_slido_data <- reactiveFileReader(time_interval,
NULL,
"https://raw.githubusercontent.com/FredHutch/itn-dashboard/main/data/itcr_slido_data.csv",
readr::read_csv)
itcr_slido_data_processed <- reactive({
itcr_slido_data() %>% clean_names() %>%
mutate(participant = coalesce(user_id, participant_id)) %>%
filter(!is.na(participant))
})
itcr_slido_data_rec <- reactive({
itcr_slido_data_processed() %>%
filter(!str_detect(event_name, "Pre")) %>% #remove pre workshop survey that doesn't ask the relevant question
select(matches("recommend_")) %>%
mutate(merged_likely_rec = as.integer(coacross(everything())))
})
output$percent_rec <- renderText({
paste0(round(sum(itcr_slido_data_rec()$merged_likely_rec >= 8, na.rm = TRUE) / sum(!is.na(itcr_slido_data_rec()$merged_likely_rec)) * 100, digits=1),
" % of responses rated their recommendation likelihood as an 8 or higher.")
})
# Data: Workshop Registrant Career Stage ----------------------------------------------------
career_stage_counts_raw <- reactiveFileReader(time_interval,
NULL,
"https://docs.google.com/spreadsheets/d/1-8vox2LzkVKzhmSFXCWjwt3jFtK-wHibRAq2fqbxEyo/edit?usp=sharing",
googlesheets4::read_sheet,
sheet = "Workshop attendee type totals")
# This data is manually curated and does NOT automatically update
#This googlesheet has the workshop name in the first column and has counts for a specific career stage in each column.
#The final row of the google sheet is the total (column sum)
career_stage_counts_summed <- reactive({
#tmp <- career_stage_counts_raw() %>%
#select(-1) %>% #drop the first column
#slice(1:(n() - 1)) #drop the last row
#colSums(tmp) #colSum to get the values that were in the last row....
if(tolower(career_stage_counts_raw() %>% slice(n()) %>% select(1)) == "total"){
t(career_stage_counts_raw() %>% slice(n()) %>% select(-1))
}
})
career_stage_processed <- reactive({
career_stage_processed <- data.frame(
Stage = rownames(career_stage_counts_summed()),
count = as.numeric(career_stage_counts_summed()[,1]),
stringsAsFactors = FALSE
)
career_stage_processed$Trainee <- ifelse(career_stage_processed$Stage %in% c("Phd student",
"postdoc",
"Master's student",
"Research tech",
"undergrad"),
"yes",
"no")
career_stage_processed
})
# Data: Poll Results ---------------------------------------------------
poll_data <- reactive({
itcr_slido_data() %>%
clean_names() %>%
mutate(merged_likely_rec = if_else(is.na(how_likely_would_you_be_to_recommend_this_workshop), how_likely_would_you_be_to_recommend_this_workshop_2,
how_likely_would_you_be_to_recommend_this_workshop))
})
poll_results <- reactive({
udpipe::udpipe_annotate(ud_model, x = poll_data()$what_did_you_like_most_about_the_workshop) %>%
as.data.frame() %>%
dplyr::filter(upos %in% c("NOUN", "ADJ", "ADV")) %>%
mutate(lemma= tolower(lemma)) %>%
count(lemma)
})
poll_rec_results <- reactive({
udpipe::udpipe_annotate(ud_model, x = poll_data()$please_share_any_recommendations_you_have_for_improvements) %>%
as.data.frame() %>%
filter(upos %in% c("NOUN", "ADJ", "ADV")) %>%
mutate(lemma= tolower(lemma)) %>%
count(lemma)
})
# Data: CRAN Downloads ----------------------------------------------------
cran_download <- reactiveFileReader(time_interval,
NULL,
"https://raw.githubusercontent.com/FredHutch/itn-dashboard/main/data/cran_download_stats.csv",
readr::read_csv)
# Data: Collaborations ----------------------------------------------------
collabs_raw <- reactiveFileReader(time_interval,
NULL,
"https://docs.google.com/spreadsheets/d/1-8vox2LzkVKzhmSFXCWjwt3jFtK-wHibRAq2fqbxEyo/edit?usp=sharing",
googlesheets4::read_sheet)
collabs_processed <- reactive({
collabs_raw() %>%
separate_rows("Category", sep = ", ", ) %>%
mutate(Category = trimws(Category)) %>%
filter(Category != "?")
})
# Table: User Totals ----------------------------------------------------
output$table_user_total <- renderDT({
DT::datatable(
user_totals(),
colnames = c("Website", "Active Users", "Avg Session Duration"),
options = list(lengthChange = FALSE, # remove "Show X entries"
searching = FALSE,
scrollY = "450px"), # remove Search box
# For the table to grow/shrink
fillContainer = TRUE,
escape = FALSE
)
})
# Table: User Engagement ----------------------------------------------------
output$table_user_engagement <- renderDT({
DT::datatable(
user_engagement(),
colnames = c("Website", "Screen Page Views per User", "Sessions",
"Screen Page Views", "Engagement Rate"),
options = list(lengthChange = FALSE, # remove "Show X entries"
searching = FALSE,
scrollY = "450px"), # remove Search box
# For the table to grow/shrink
fillContainer = TRUE,
escape = FALSE
)
})
# Plot: Visitors across Educational Resources ----------------------------------------------------
output$plot_visitor_website <- renderPlot({
itcr_course_data() %>%
# Filter out ITN Website since it is not an "Educational Resource"
filter(!(website %in% c("ITN Website", "widget", "DaSL Collection",
"proof", "metricminer.org", "OTTR website",
"Developing_WDL_Workflows", "Using Leanpub Course",
"ocdo.fredhutch.org"))) %>%
ggplot(aes(x = reorder(website, -totalUsers), y = totalUsers, fill = target_audience)) +
geom_bar(stat = "identity") +
geom_text(aes(label = totalUsers), hjust = 1.05,
colour = "lightgray", fontface = "bold") +
theme_classic() +
coord_flip() +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "inside",
legend.position.inside = c(0.75,0.75)) +
labs(x = NULL,
y = "Number of Visitors",
fill = "Target Audience") +
scale_fill_manual(values=cbLEPalette) +
guides(fill=guide_legend(nrow=3))
})
# Plot: Engagement by Modality ----------------------------------------------------
output$plot_engagement_modality <- renderPlot({
course_processed() %>%
filter(modality == input$modality) %>%
# Some courses have 0 learners
filter(number_of_learners > 0) %>%
ggplot(aes(x = fct_reorder(course_name, number_of_learners),
y = number_of_learners, fill = `Target Audience`)) +
geom_col() +
geom_text(aes(label = number_of_learners), hjust = 1.05,
colour = "lightgray", fontface = "bold") +
coord_flip() +
scale_fill_manual(values=cbLEPalette) +
theme_classic() +
theme(legend.position = "inside",
legend.position.inside = c(0.75, 0.25),
text = element_text(size = 17, family = "Arial")) +
labs(x = NULL,
y = "Number of Learners") +
guides(fill=guide_legend(nrow=3))
})
# Plot: Website Engagement ----------------------------------------------------
output$plot_engagement_website <- renderPlot({
itcr_course_data() %>%
clean_names() %>%
select(website, screen_page_views_per_user, average_session_duration,
event_count_per_user, engagement_rate, target_audience) %>%
pivot_longer(!c(website, target_audience),
names_to = "metric_name",
values_to = "value") %>%
filter(!(website %in% c("ITN Website", "OTTR website", "metricminer.org")),
metric_name == input$metric) %>%
ggplot(aes(x = website, y = value, fill = target_audience)) +
geom_bar(position = "dodge", stat = "identity") +
geom_text(aes(label = round(value, 1), hjust = 1.05),
colour = "lightgray", fontface = "bold") +
coord_flip() +
theme_classic() +
labs(x = NULL,
y = NULL,
fill = "Target Audience") +
scale_fill_manual(values=cbLEPalette, limits = c("Leadership", "New to data", "Software developers")) +
scale_x_discrete(limits = c("Leadership in Cancer Informatics", "NIH Data Sharing", "Ethical Data Handling", "Overleaf and Latex for Scientific Articles", "AI for Decision Makers",
"Reproducibility in Cancer Informatics", "Choosing Genomics Tools", "Computing for Cancer Informatics",
"Documentation and Usability", "Advanced Reproducibility", "AI for Efficient Programming", "GitHub Automation for Scientists")) +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "bottom") +
guides(fill=guide_legend(nrow=3))
})
# Plot: Course Engagement by Target Audience ----------------------------------------------------
output$plot_engagement_target <- renderPlot({
itcr_course_data_long() %>%
filter(!(website %in% c("widget", "DaSL Collection", "Developing_WDL_Workflows", "proof", "Using Leanpub Course", "ocdo.fredhutch.org"))) %>%
group_by(modality, target_audience) %>%
summarize(total_learners = sum(learner_count, na.rm = TRUE)) %>%
ggplot(aes(x = reorder(modality, -total_learners), y = total_learners, fill = target_audience)) +
geom_bar(stat = "identity", na.rm = TRUE) +
geom_text(aes(label = total_learners), hjust = 1.055, na.rm = TRUE,
colour = "lightgray", fontface = "bold") +
coord_flip() +
theme_classic() +
theme(legend.position = "none",
text = element_text(size = 17, family = "Arial")) +
labs(x = NULL,
y = "Visitors/Enrollees",
fill = "Target Audience") +
#ylim(c(0, 4200)) +
facet_wrap(~target_audience, nrow=3) +
scale_fill_manual(values=cbLEPalette, limits = c("Leadership", "New to data", "Software developers"))
})
# Plot: Learner by Course ----------------------------------------------------
output$plot_learner_course <- renderPlot({
itcr_course_data_long() %>%
group_by(website, target_audience) %>%
summarize(total_learners = sum(learner_count, na.rm = TRUE)) %>%
filter(!(website %in% c("widget", "DaSL Collection", "Developing_WDL_Workflows", "proof", "Using Leanpub Course", "ocdo.fredhutch.org"))) %>%
ggplot(aes(x = reorder(website, -total_learners), y = total_learners, fill = target_audience)) +
geom_bar(stat = "identity") +
geom_text(aes(label = total_learners), hjust = 1.05, na.rm = TRUE,
colour="lightgray", fontface = "bold") +
labs(x = NULL,
y = "Total Learners by Course",
fill = "Target Audience",
title = NULL) +
coord_flip() +
theme_classic() +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "inside",
legend.position.inside = c(0.75, 0.75)) +
scale_fill_manual(values=cbLEPalette) +
guides(fill=guide_legend(nrow=3))
})
# Plot: Coursera Learners ----------------------------------------------------
output$plot_coursera <- renderPlot({
itcr_course_data() %>%
filter(coursera_count > 0) %>%
ggplot(aes(x = reorder(website, -coursera_count), y = coursera_count, fill = target_audience)) +
geom_bar(stat = "identity", na.rm = TRUE) +
geom_text(aes(label = coursera_count), hjust = 1.05, na.rm = TRUE,
colour = "lightgray", fontface = "bold") +
coord_flip() +
theme_classic() +
labs(x = NULL,
y = "Coursera enrollments",
fill = "Target Audience",
title = NULL) +
ylim(c(0, 1200)) +
scale_fill_manual(values = cbLEPalette) +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "inside",
legend.position.inside = c(0.75, 0.75)) +
guides(fill=guide_legend(nrow=3))
})
# Plot: Leanpub Learners ----------------------------------------------------
output$plot_leanpub <- renderPlot({
itcr_course_data() %>%
filter(leanpub_count > 0) %>%
ggplot(aes(x = reorder(website, -leanpub_count), y = leanpub_count, fill = target_audience)) +
geom_bar(stat = "identity", na.rm = TRUE) +
geom_text(aes(label = leanpub_count), hjust = 1.05, na.rm = TRUE,
colour = "lightgray", fontface = "bold") +
coord_flip() +
theme_classic() +
labs(x = NULL,
y = "Leanpub enrollments",
fill = "Target Audience",
title = NULL) +
ylim(c(0, 40)) +
scale_fill_manual(values = cbLEPalette) +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "inside",
legend.position.inside = c(0.75, 0.75)) +
guides(fill=guide_legend(nrow=3))
})
# Plot: Learners by Launch Date ----------------------------------------------------
output$plot_learner_launch_date <- renderPlot({
itcr_course_data() %>%
filter(!(website %in% c("ITN Website", "OTTR website", "metricminer.org"))) %>%
mutate(duration = today() - website_launch) %>%
ggplot(aes(x = duration, y = website_count, color = target_audience)) +
geom_point() +
theme(panel.grid = element_line("black", linewidth = 0.25),
panel.background = element_blank(),
panel.border = element_rect("black", fill=NA, linewidth=0.5),
legend.position = "bottom",
text = element_text(size = 17, family = "Arial")) +
labs(x = "How long the course has been out (days)",
y = "Bookdown Views",
color = "Target Audience",
title = NULL) +
scale_color_manual(values=cbLEPalette, limits = c("Leadership", "New to data", "Software developers")) +
ggrepel::geom_text_repel(
aes(label = website),
family = "Poppins",
size = 3.5,
min.segment.length = 0,
seed = 42,
box.padding = 0.5,
max.overlaps = Inf,
arrow = arrow(length = unit(0.010, "npc")),
nudge_x = .15,
nudge_y = .5,
color = "black"
)
})
# Plot: Recommendation likelihood ------------------------------------------------------
output$plot_workshop_recommendation <- renderPlot({
itcr_slido_data_processed() %>%
filter(!str_detect(event_name, "Pre")) %>% #remove pre workshop survey that doesn't ask the relevant question
select(matches("recommend_")) %>%
mutate(merged_likely_rec = as.integer(coacross(everything()))) %>%
ggplot(aes(merged_likely_rec)) +
geom_bar(fill = "#28ae80") +
theme_classic() +
scale_x_continuous(breaks= c(1:10), labels=c(1:10), limits=c(0.5,10.5)) +
coord_cartesian(clip="off") +
geom_text(stat = "count", aes(label = after_stat(count)), vjust= 1.4,
colour = "lightgray", fontface = "bold") +
theme(text = element_text(size = 17, family = "Arial")) +
labs(y = "Count",
x = "Rating") +
ggtitle("How likely are you to recommend this workshop?") +
annotation_custom(textGrob("Most\nLikely", gp=gpar(fontsize=8, fontface = "bold")),xmin=10,xmax=10,ymin=-13,ymax=-13) +
annotation_custom(textGrob("Least\nLikely", gp=gpar(fontsize=8, fontface= "bold")),xmin=1,xmax=1,ymin=-13,ymax=-13)
})
# Plot: Workshop Relevance (e.g., Positive impact likelihood) ---------------------------------------------------
output$plot_workshop_relevance <- renderPlot({
itcr_slido_data_processed() %>%
filter(!str_detect(event_name, "Pre")) %>% #remove pre workshop survey that doesn't ask the relevant question
select(matches("relevant|positive_impact")) %>%
select(!matches("current_research_work")) %>%
mutate(merged_relevant_likely = as.integer(coacross(everything()))) %>%
ggplot(aes(merged_relevant_likely)) +
geom_bar(fill = "#28ae80") +
theme_classic() +
scale_x_continuous(breaks= c(1:10), labels=c(1:10), limits=c(0.5,10.5)) +
coord_cartesian(clip="off") +
geom_text(stat = "count", aes(label = after_stat(count)), vjust= 1.4,
colour = "lightgray", fontface = "bold") +
theme(text = element_text(size = 17, family = "Arial")) +
labs(y = "Count",
x = "Rating") +
ggtitle("How likely is this workshop to have\na positive impact on your work?") +
annotation_custom(textGrob("Most\nLikely", gp=gpar(fontsize=8, fontface = "bold")),xmin=10,xmax=10,ymin=-5.5,ymax=-5.5) +
annotation_custom(textGrob("Least\nLikely", gp=gpar(fontsize=8, fontface= "bold")),xmin=1,xmax=1,ymin=-5.5,ymax=-5.5)
})
# Plot: Pre- and post- workshop confidence (pooled) ----------------------------------------
output$plot_workshop_confidence_pooled <- renderPlot({
rbind(
itcr_slido_data_processed() %>%
filter(!str_detect(event_name, "Q2-NIH_")) %>%
select(event_name, contains("confident")) %>%
mutate(across(contains("confident"), as.character)) %>% #getting an error about combining characters and doubles, so making everything a character before changing to an integer later after dropping irrelevant characters
pivot_longer(contains("confident"), values_to = "value", names_to = "question") %>%
mutate(pre_post = if_else(grepl("now", question), "post", "pre")) %>%
filter(str_length(value) <= 2) %>% #filter out the ones that are phrases and not numbers
filter(!str_detect(event_name, "GLBIO")) %>% #max ratings of 5 so filter out
select(value, pre_post),
itcr_slido_data_processed() %>%
filter(event_name == "Q2-NIH_PreSurvey") %>%
select(contains("confident")) %>%
mutate(across(contains("confident"), as.character)) %>% #getting an error about combining characters and doubles, so making everything a character before changing to an integer later after dropping irrelevant characters
pivot_longer(everything(), values_to = "value", names_to = "question") %>%
mutate(pre_post = "pre") %>%
select(value, pre_post),
itcr_slido_data_processed() %>%
filter(str_detect(event_name, "Q2-NIH_") & event_name != "Q2-NIH_PreSurvey") %>%
select(contains("confident")) %>%
mutate(across(contains("confident"), as.character)) %>% #getting an error about combining characters and doubles, so making everything a character before changing to an integer later after dropping irrelevant characters
pivot_longer(everything(), values_to = "value", names_to = "question") %>%
mutate(pre_post = "post") %>%
select(value, pre_post)
) %>%
drop_na() %>%
mutate(value = as.integer(value),
pre_post = factor(pre_post, levels = c("pre", "post"))
) %>%
ggplot(aes(x = value, y=pre_post, fill=pre_post)) +
geom_boxplot(outliers = FALSE) +
geom_jitter(aes(fill=pre_post), height=0.1, width=0.35, alpha=0.4, size=1.5, shape=21, color="black", stroke=1.5) +
theme_bw() + theme(panel.background = element_blank()) +
theme(legend.position = "bottom") +
xlab("Confidence Rank") + scale_x_continuous(breaks = 1:10, labels = 1:10) +
ylab("") +
ggtitle("How confident do you feel about ...") +
scale_fill_discrete(name = "Pre or post workshop?") +
coord_cartesian(clip = 'off') +
annotation_custom(textGrob("Most\nConfident", gp=gpar(fontsize=8, fontface = "bold")),xmin=10,xmax=10,ymin=0.1,ymax=0.1) +
annotation_custom(textGrob("Least\nConfident", gp=gpar(fontsize=8, fontface= "bold")),xmin=1,xmax=1,ymin=0.1,ymax=0.1) +
theme(axis.text.y=element_blank(),
axis.ticks.y=element_blank(),
text = element_text(size = 17, family = "Arial"))
})
# Plot: Pre- and post- workshop confidence (workshop specific) ----------------------------
output$plot_workshop_confidence <- renderPlot({
})
# Plot: Workshop Career Stage ----------------------------------------------------
output$plot_workshop_career_stage <- renderPlot({
career_stage_processed() %>%
ggplot(aes(x = reorder(Stage, -count), y = count, fill = Trainee)) +
geom_bar(stat = "identity") +
geom_text(aes(label = count), hjust = 1.2,
colour ="lightgray", fontface = "bold") +
coord_flip() +
xlab(NULL) +
ylab("Number of Registrants") +
theme_bw() +
theme(panel.background = element_blank(),
panel.grid = element_blank(),
text = element_text(size = 17, family = "Arial")) +
scale_fill_manual(values = c("#440154", "#28ae80"))
})
# Plot: Workshop Review ----------------------------------------------------
output$plot_workshop_review <- renderPlot({
wordcloud::wordcloud(words = poll_results()$lemma,
freq = poll_results()$n,
colors = c("#98fb98", "#83D475", "#355E3B"),
min.freq = 3, scale = c(3, .4))
})
# Plot: Workshop Feedback ----------------------------------------------------
output$plot_workshop_improvement <- renderPlot({
wordcloud::wordcloud(words = poll_rec_results()$lemma,
freq= poll_rec_results()$n,
colors = c("#98fb98", "#83D475", "#355E3B"),
min.freq = 3, scale = c(4, .4))
})
# Plot: Monthly CRAN Download ----------------------------------------------------
output$plot_monthly_cran_download <- renderPlot({
cran_download() %>%
ggplot(aes(Month, monthly_downloads, group=package, color = package)) +
geom_line() +
geom_point() +
scale_colour_manual(values=viridis_cc) +
theme(panel.background = element_blank(),
panel.grid = element_blank(),
text = element_text(size = 17, family = "Arial")) +
geom_vline(aes(xintercept = "2019-05"), linetype='dashed', color = '#addc30') + #text2speech published date
geom_vline(aes(xintercept="2022-02"), linetype='dashed', color = '#28ae80') + #ottrpal published date
geom_vline(aes(xintercept="2023-07"), linetype='dashed', color = '#2c728e') + #conrad published date
geom_vline(aes(xintercept="2024-02"), linetype="dashed", color = '#fde725') + #metricminer published date
theme(axis.text.x = element_text(angle = 90),
legend.position = "bottom") + #clean up x-axis labels
labs(x = NULL,
y = "Monthly Downloads",
color = "R Packages")
})
# Table: Total CRAN downloads by package
output$table_cran_downloads <- renderDT({
DT::datatable(
cran_download() %>%
group_by(package) %>%
summarize(total_downloads = sum(monthly_downloads)),
colnames = c("Package", "Total Downloads"),
options = list(lengthChange = FALSE, # remove "Show X entries"
searching = FALSE,
scrollY = "150px"), # remove Search box
# For the table to grow/shrink
fillContainer = TRUE,
escape = FALSE
)
})
# Table: Total CRAN downloads by package last 6 months
output$table_cran_sixmonths <- renderDT({
DT::datatable(
cran_download() %>%
filter(Month > format(as.Date(today() - months(6)), "%Y-%m")) %>% #within 6 months
group_by(package) %>%
summarize(total_downloads = sum(monthly_downloads)),
colnames = c("Package", "Total Downloads"),
options = list(lengthChange = FALSE, # remove "Show X entries"
searching = FALSE,
scrollY = "150px"), # remove Search box
# For the table to grow/shrink
fillContainer = TRUE,
escape = FALSE
)
})
# Plot: All Collaborations ----------------------------------------------------
output$plot_collaboration_all <- renderPlot({
collabs_processed() %>%
count(Category) %>%
ggplot(aes(y = n, x = reorder(Category,-n), fill = Category)) +
geom_bar(position = "dodge", stat = "identity") +
geom_text(aes(label = n), hjust = 1.05,
colour = "white", fontface = "bold") +
coord_flip() +
theme_classic() +
theme(strip.text.x = element_text(size = 6),
legend.position="none",
text = element_text(size = 17, family = "Arial"),
plot.margin = unit(c(.75,.5,.5,.5), "cm")) +
xlab(NULL) +
ylab(NULL)
})
# Plot: ITCR Collaborations ----------------------------------------------------
output$plot_collaboration_itcr <- renderPlot({
collabs_processed() %>%
filter(ITN_ITCR_or_external == "ITCR") %>%
count(Category) %>%
ggplot(aes(y =n, x=reorder(Category, -n), fill = Category )) +
geom_bar(position="dodge", stat = "identity") +
geom_text(aes(label = n), hjust = 1.05,
colour = "white", fontface = "bold") +
coord_flip() +
theme_classic() +
theme(text = element_text(size = 17, family = "Arial"),
legend.position = "none",
plot.margin = unit(c(.75,.5,.5,.5), "cm")) +
xlab(NULL) +
ylab(NULL)
})
# Plot: All Collaborations colored by ITCR or not ------------------------------
output$plot_collaboration_all_color <- renderPlot({
collabs_processed() %>%
group_by(Category, ITN_ITCR_or_external) %>%
mutate(ITN_ITCR_or_external =
factor(case_when(ITN_ITCR_or_external == "external" ~ "Not ITCR",
ITN_ITCR_or_external == "external (was after leaving)" ~ "Not ITCR",
ITN_ITCR_or_external == "external NIH/NCI intermural" ~ "Not ITCR",
ITN_ITCR_or_external == "ITCR" ~ "ITCR",
ITN_ITCR_or_external == "ITN" ~ "ITN",
ITN_ITCR_or_external == "NCI" ~ "Not ITCR",
ITN_ITCR_or_external == "neither" ~ "Not ITCR",
ITN_ITCR_or_external == "NIH" ~ "Not ITCR"),
levels = rev(c("ITCR", "Not ITCR", "ITN")))) %>%
summarize(n= n()) %>%
ggplot(aes(y = n, x = reorder(Category,-n, sum), fill = ITN_ITCR_or_external)) +
geom_bar(position = "stack", stat = "identity") +
geom_text(aes(label = after_stat(y), group = Category), hjust = 1.05,
stat = 'summary', fun = sum,
colour = "white", fontface = "bold") +
coord_flip() +
theme_classic() +
labs(fill = "ITCR Collab?") +
theme(strip.text.x = element_text(size = 6),
legend.position="inside",
legend.position.inside = c(0.75, 0.75),
text = element_text(size = 17, family = "Arial"),
plot.margin = unit(c(.75,.5,.5,.5), "cm")) +
xlab(NULL) +
ylab(NULL) +
scale_fill_discrete(na.translate = F)
})
}
# Code for Deployment to Hutch servers
addResourcePath("/i", file.path(getwd(), "www"))
options <- list()
if (!interactive()) {
options$port = 3838
options$launch.browser = FALSE
options$host = "0.0.0.0"
}
shinyApp(ui, server, options=options)