-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.R
1247 lines (915 loc) · 37.5 KB
/
server.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
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#' ---
#' title: "02: server.R"
#' output:
#' rmarkdown::html_document:
#' toc: yes
#' toc_depth: 2
#' toc_float: yes
#'params:
#' building_docs: true
#'---
#+ include=FALSE
## for knitting into documentation file
if(exists("params") && !is.null(params$building_docs) && params$building_docs == TRUE ){
knitr::opts_chunk$set(echo = TRUE, eval = FALSE)
}
#' NOTE: Section headers on this file are duplicated.
#' One set of headers exist for knitting this to an Rmarkdown (for documentation)
#' The second set are hooks for RStudio's document outline feature.
#' Increase upload size. See https://shiny.rstudio.com/articles/upload.html
options(shiny.maxRequestSize = 50 * 1024^2)
server <- function(input, output) {
#' # Source server functions
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Source server functions ------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Load in the primary functions that will be called within server.R
source(here::here("helper_scripts/server_functions.R"), local = T)
#' # Country-specific load data UI
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Country-specific load data UI ------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Here we call the function that loads all the country-specific
#' UI elements required in the "Choose dataset to analyse" box.
country_specific_UI_for_loading_data(input = input, output = output)
#' # Load data reactives
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Load data reactives --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Each of the "read_file-" reactives sources its namesake function.
#' These functions are called in a reactive context to ensure that if the input data changes,
#' all the output graphs will change as well.
#' ## read_file_raw_reactive
# ~~~~ read_file_raw_reactive --------------------
#' The read_file_raw function does either of two things.
#' - For countries using Go.Data, it takes in the input credentials,
#' logs into a Go.Data session, and returns a list with the requisite dataframes.
#' - For countries using KoboCollect, it takes in the two uploaded csv files,
#' (contact list and follow-up list), and returns them as a list of a dataframes.
read_file_raw_reactive <- reactive({
req(input$data_to_use)
req(input$analyze_action_bttn)
read_file_raw()
})
#' ## read_file_transformed_reactive
# ~~~~ read_file_transformed_reactive -----------------
#' The 'read_file_transformed' function takes in data from read_file_raw_reactive,
#' and 'transforms' it into a single, 'long' dataframe,
#' with one row per contact-follow-up-day
read_file_transformed_reactive <- reactive({
req(input$data_to_use)
req(input$analyze_action_bttn)
read_file_transformed(tracing_data_raw = read_file_raw_reactive())
})
#' ## read_file_filtered_reactive
# ~~~~ read_file_filtered_reactive ------------------------
#' The 'read_file_filtered' function takes in data from read_file_transformed_reactive
#' It also takes in a date_of_review variable.
#' It filters out contacts who had not begun followup by the selected date_of_review
#' Also, for contacts being followed, "future" are relabelled as such.
#' The output of read_file_filtered is a df that feed most graphs in the app.
read_file_filtered_reactive <- reactive({
req(input$analyze_action_bttn)
read_file_filtered(contacts_df_long_transformed = read_file_transformed_reactive(),
todays_date = input$select_date_of_review)
})
#' # Action button observer
# ~~~~ Action button observer ---------------------------
#' This observer simply triggers or re-triggers 'read_file_transformed_reactive'
#' whenever the analyze action button is pressed
observeEvent(input$analyze_action_bttn, {
read_file_transformed_reactive()
})
#' # Data overview section
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Data overview section----
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' The plots below take in data from 'read_file_transformed_reactive'
#' and output summary graphics.
#' Recall that the output of 'read_file_transformed_reactive' is
#' the unfiltered, full, "long" dataframe, with one row per contact-follow-up-day.
#' ## data_completeness_plot
# ~~~~ data_completeness_plot ---------------------------
#' Here we output a visualization of the entire long dataframe.
#' Uses the viz_dat function
output$data_completeness_plot <-
renderPlot({
req(read_file_transformed_reactive())
if (input$data_to_use == "Use uploaded data") {
req(input$uploaded_data_contacts_list)
req(input$uploaded_data_follow_up_list)
}
if (input$data_to_use == "Use preloaded data") {
req(input$preloaded_data_choice)
}
read_file_transformed_reactive() %>%
data_completeness_plot()
})
#' ## data_cardinality_plot
# ~~~~ data_cardinality_plot ---------------------------
#' This is a plot using the 'inspect_cat' function of the inspectdf package
output$data_cardinality_plot <-
renderPlot({
req(read_file_transformed_reactive())
if (input$data_to_use == "Use uploaded data") {
req(input$uploaded_data_contacts_list)
req(input$uploaded_data_follow_up_list)
}
if (input$data_to_use == "Use preloaded data") {
req(input$preloaded_data_choice)
}
read_file_transformed_reactive() %>%
data_cardinality_plot()
})
#' ## reactable_table
# ~~~~ reactable_table ---------------------------
#' Here, we output the entire long table for easy viewing, or searching
output$reactable_table <-
renderReactable({
req(read_file_transformed_reactive())
if (input$data_to_use == "Use uploaded data") {
req(input$uploaded_data_contacts_list)
req(input$uploaded_data_follow_up_list)
}
if (input$data_to_use == "Use preloaded data") {
req(input$preloaded_data_choice)
}
read_file_transformed_reactive() %>%
reactable_table()
})
#' # Date selection
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Date selection --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' This tab contains the primary graphs and tables that pertain to all contacts.
#' (The next tab contains information pertaining to only active contacts,
#' that is, contacts who are actively under surveillance)
#' ## select_date_of_review
# ~~~~ select_date_of_review --------------------
#' This picker lets you select a present or historical date,
#' letting you see what the data looked like at each time point.
#' The range of dates that can be picked are bounded
#' by the range of dates in the dataframe (passed from 'read_file_transformed_reactive').
#' The picker also guesses what the date of review is.
#' Basically, it obtains the last date for which follow-up status was not "missing" or "future",
#' (the last day on which there was any contact follow-up),
#' and assumes this is the date on which the user would like to view the data.
output$select_date_of_review <- renderUI({
## date selection needs to use the unfiltered data frame
## because the selection from this input feeds the filtering function
req(input$data_to_use)
req(read_file_transformed_reactive())
flattened_dates <-
read_file_transformed_reactive() %>%
select(follow_up_date) %>%
pull(1)
min_date <- min(flattened_dates, na.rm = T)
max_date <- max(flattened_dates, na.rm = T)
# get the last date for which follow-up status was not "missing" or "future"
# assume that that is the date as on which the data is being analyzed
todays_date_imputed_from_data <-
read_file_transformed_reactive() %>%
filter(follow_up_status != "Suivi futur" &
follow_up_status != "Manquant" &
follow_up_status != "Future follow-up" &
follow_up_status != "NA" &
!is.na(follow_up_status)) %>%
select(follow_up_date) %>%
pull(1) %>%
max(na.rm = T)
dateInput("select_date_of_review",
label = "Select date of review",
value = todays_date_imputed_from_data,
min = min_date,
max = max_date
)
})
#' # Generate downloadable report
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Generate downloadable report --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' ## select_report_format
#' Select which of five formats to use for the downloaded report.
#' (As at May 13, 2021, the PDF format is not working.
#' Should hopefully work when this issue is sorted by the RStudio team: https://bit.ly/3oj0Kkv
#' )
# ~~~~ select_report_format---------------------------
output$select_report_format <- renderUI({
req(input$select_date_of_review)
selectInput("report_format",
label = "Select format",
choices = c(
"pptx",
"docx",
#"pdf",
"html (page)",
"html (slides)"
)
)
})
#' ## download_report_button
#' This is placed within a renderUI context so that we can hide it conditionally
# ~~~~ download_report_button---------------------------
output$download_report_button <- renderUI({
req(input$select_date_of_review)
tagList(
HTML("<p style='font-size:4px'> <br><br> </p>"),
downloadBttn("report",
label = "Download report",
style = "jelly",
color = "primary", size = "md"
)
)
})
#' ## download_report_function
# ~~~~ download_report_function---------------------------
output$report <- download_report_function()
#' # Dynamic filtering section
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Dynamic filtering section --------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' ## filters
#' A dynamic filtering section. The code below renders an input picker for each
#' column in the dataset. The code is quite hairy, but we have tried to comment it extensively.
# ~~~~ ouput$filters----
output$filters <- renderUI({
req(input$analyze_action_bttn)
req(input$select_date_of_review)
req(input$filter_or_not)
## filters are only generated if the filter_or_not slider is set to TRUE
if ((!is.null(input$filter_or_not)) && input$filter_or_not == TRUE) {
my_data <-
read_file_transformed_reactive() %>%
as.data.frame() %>% ## not sure why but tibble doesn't work
## filters not created for rows that change across each contact
select(-any_of(cols_to_exclude_from_filters)) %>%
## no filters for columns that are all NA
janitor::remove_empty(which = "cols")
labels <- sort(names(my_data))
## unique values of each column
choices <- lapply(1:length(labels), function(x) {
unique(my_data[, labels[x]])
})
## render a selector for each column
lapply(1:length(labels), function(i) {
## create output$gender, output$region and so on based on column names
output[[labels[[i]]]] <- renderUI({
## first subset the data to that column
col <- my_data[, labels[i]]
## then, below, we render an input picker based on whether the column is a character, number or date
## and also based on whether or not the column has NA values
## CHARACTER AND FACTOR COLUMNS ~~~~~~~~~~~~~~~~~~~
if (is.character(col) | is.factor(col)) {
## calc unique length to decide whether to add search bar
length_choices <- length(na.omit(choices[[i]]))
search_or_not <- if(length_choices >= 10 ) TRUE else FALSE
## create pickerInput.
## this would be accessed as input$gender, input$region and so on
input_UI_element <-
pickerInput(inputId = labels[[i]],
label = labels[[i]],
choices = na.omit(choices[[i]]),
selected = na.omit(choices[[i]]),
options = list(`actions-box` = TRUE,
`virtual-scroll` = TRUE,
`live-search` = search_or_not,
`live-search-placeholder` = "Enter search term",
`dropup-auto` = FALSE),
multiple = TRUE)
## if col has NA values, add checkboxinput asking whether to keep these
if (any(is.na(col))) {
tagList(
input_UI_element,
checkboxInput(inputId = paste0("na_", labels[[i]]),
label = paste0("Include contacts w. missing values for ",
labels[[i]], "?"),
value = TRUE))
## otherwise, print/return just the primary input picker
} else { input_UI_element }
## NUMERIC COLUMNS ~~~~~~~~~~~~~~~~~~~
## same procedure as with character columns
} else if (is.numeric(col)) {
input_UI_element <-
sliderInput(inputId = labels[[i]],
label = labels[[i]],
min = min(col, na.rm = TRUE),
max = max(col, na.rm = TRUE),
value = c(min(col, na.rm = TRUE),
max(col, na.rm = TRUE)))
## if col has NA values, add checkboxinput asking whether to keep these
if (any(is.na(col))) {
tagList(
input_UI_element,
checkboxInput(inputId = paste0("na_", labels[[i]]),
label = paste0("Include contacts w. missing values for ",
labels[[i]], "?"),
value = TRUE))
## otherwise, print/return just the primary input picker
} else { input_UI_element }
## DATE COLUMNS ~~~~~~~~~~~~~~~~~~~
} else if (lubridate::is.Date(col)) {
input_UI_element <-
dateRangeInput(inputId = labels[[i]],
label = labels[[i]],
min = min(col, na.rm = TRUE),
max = max(col, na.rm = TRUE),
start = min(col, na.rm = TRUE),
end = max(col, na.rm = TRUE))
## if col has NA values, add checkboxinput asking whether to keep these
if (any(is.na(col))) {
tagList(
input_UI_element,
checkboxInput(inputId = paste0("na_", labels[[i]]),
label = paste0("Include contacts w. missing values for ",
labels[[i]], "?"),
value = TRUE))
## otherwise, print/return just the primary input picker
} else { input_UI_element }
}
})
}
)
## the large lapply function above created an input picker for each column
## now we output all those input pickers,
## as in uiOutput("gender") and so on.
lapply(1:length(labels), function(i) {
uiOutput(labels[[i]])
})
}
## these uiOutputs are packaged into a larger output, output$filters,
## which will, finally, be placed in our UI, as in uiOutput("filters")
})
output$additional_filters_text <- renderUI({
req(input$filter_or_not)
if ((!is.null(input$filter_or_not)) && input$filter_or_not == TRUE) {
tagList(
h6("Use the input pickers and sliders to filter your data"),
HTML("<font size='1'>
Note that the following are not shown: <br>
• Empty columns; <br>
• Name columns; and <br>
• the date of follow-up column <br>
Also note that the options for each filter
do not react to selections on other filters.
</font>")
)
} else {
HTML(c(" "))
}
})
#' # OUTPUTS PERTAINING TO ALL CONTACTS
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ OUTPUTS PERTAINING TO ALL CONTACTS ----
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' # Value boxes
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ Value boxes --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Below we call the value-box functions and return their outputs.
#' These functions return an HTML Shiny value-box when the report_format parameter
#' is "shiny", and a ggplot-based value-box otherwise.
#' Like most of the remaining functions that the app uses, these take in
#' two primary inputs: the long contacts dataframe (one row per follow-up-day),
#' and the date of review.
#' ## new_contacts_per_day_value_box
# ~~~~ new_contacts_per_day_value_box ----
output$new_contacts_per_day_value_box <-
renderValueBox({
req(input$select_date_of_review)
req(input$analyze_action_bttn)
## require that there is actually data to be visualized
shiny::validate(need(nrow(read_file_filtered_reactive()) > 0, message = FALSE))
new_contacts_per_day_value_box(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review)
})
#' ## cumulative_contacts_value_box
# ~~~~ cumulative_contacts_value_box ----
output$cumulative_contacts_value_box <-
renderValueBox({
req(input$select_date_of_review)
req(input$analyze_action_bttn)
shiny::validate(need(nrow(read_file_filtered_reactive()) > 0, message = FALSE))
cumulative_contacts_value_box(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review)
})
#' ## contacts_under_surveillance_value_box
# ~~~~ contacts_under_surveillance_value_box ----
output$contacts_under_surveillance_value_box <-
renderValueBox({
req(input$select_date_of_review)
req(input$analyze_action_bttn)
shiny::validate(need(nrow(read_file_filtered_reactive()) > 0, message = FALSE))
contacts_under_surveillance_value_box(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review)
})
#' ## pct_contacts_followed_value_box
# ~~~~ pct_contacts_followed_value_box ----
output$pct_contacts_followed_value_box <-
renderValueBox({
req(input$select_date_of_review)
req(input$analyze_action_bttn)
shiny::validate(need(nrow(read_file_filtered_reactive()) > 0, message = FALSE))
pct_contacts_followed_value_box(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review)
})
#' # new_contacts_today
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ new_contacts_today --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' These functions show the number of
#' of contacts over admin level 1 and admin level 2.
#' ## new_contacts_today_row_title
# ~~~~ new_contacts_today_row_title ----
output$new_contacts_today_row_title <- renderUI({
req(input$select_date_of_review)
new_contacts_today_row_title(input$select_date_of_review)
})
#' ## new_contacts_today_bar_chart
# ~~~~ new_contacts_today_bar_chart ----
output$new_contacts_today_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
new_contacts_today_bar_chart(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## new_contacts_today_sunburst_plot
# ~~~~ new_contacts_today_sunburst_plot ----
output$new_contacts_today_sunburst_plot <-
renderHighchart({
req(input$select_date_of_review)
new_contacts_today_sunburst_plot(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## new_contacts_today_table
# ~~~~ new_contacts_today_table ----
output$new_contacts_today_table <-
renderReactable({
req(input$select_date_of_review)
new_contacts_today_table(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## new_contacts_today_text
# ~~~~ new_contacts_today_text ----
output$new_contacts_today_text <-
renderUI({
req(input$select_date_of_review)
new_contacts_today_text(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' # new_contacts_historical
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ new_contacts_historical -----------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Functions showing how the number of contacts who are on follow-up day 1
#' ## new_contacts_historical_row_title
# ~~~~ new_contacts_historical_row_title ----
output$new_contacts_historical_row_title <- renderUI({
req(input$select_date_of_review)
new_contacts_historical_row_title()
})
#' ## new_contacts_historical_bar_chart
# ~~~~ new_contacts_historical_bar_chart ----
output$new_contacts_historical_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
new_contacts_historical_bar_chart(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## new_contacts_historical_bar_chart_relative
# ~~~~ new_contacts_historical_bar_chart_relative ----
output$new_contacts_historical_bar_chart_relative <-
renderHighchart({
req(input$select_date_of_review)
new_contacts_historical_bar_chart_relative(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## new_contacts_historical_text
# ~~~~ new_contacts_historical_text ----
output$new_contacts_historical_text <-
renderUI({
req(input$select_date_of_review)
new_contacts_historical_text(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' # cumul_contacts_today
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ cumul_contacts_today --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Below we call the contacts_per_admin_1 functions. These show the distribution
#' of contacts over admin level 1 and admin level 2.
#' ## cumul_contacts_today_row_title
# ~~~~ cumul_contacts_today_row_title ----
output$cumul_contacts_today_row_title <- renderUI({
req(input$select_date_of_review)
cumul_contacts_today_row_title(input$select_date_of_review)
})
#' ## cumul_contacts_today_table
# ~~~~ cumul_contacts_today_table ----
output$cumul_contacts_today_table <-
renderReactable({
req(input$select_date_of_review)
cumul_contacts_today_table(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## cumul_contacts_today_sunburst_plot
# ~~~~ cumul_contacts_today_sunburst_plot ----
output$cumul_contacts_today_sunburst_plot <-
renderHighchart({
req(input$select_date_of_review)
cumul_contacts_today_sunburst_plot(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## cumul_contacts_today_bar_chart
# ~~~~ cumul_contacts_today_bar_chart ----
output$cumul_contacts_today_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
cumul_contacts_today_bar_chart(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## cumul_contacts_today_text
# ~~~~ cumul_contacts_today_text ----
output$cumul_contacts_today_text <-
renderUI({
req(input$select_date_of_review)
cumul_contacts_today_text(
contacts_df_long = read_file_filtered_reactive()
)
})
#' # cumul_contacts_historical
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ cumul_contacts_historical -----------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Functions showing the cumulative number of contacts over time.
#' ## cumul_contacts_historical_row_title
# ~~~~ cumul_contacts_historical_row_title ----
output$cumul_contacts_historical_row_title <- renderUI({
req(input$select_date_of_review)
cumul_contacts_historical_row_title()
})
#' ## cumul_contacts_historical_bar_chart
# ~~~~ cumul_contacts_historical_bar_chart ----
output$cumul_contacts_historical_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
cumul_contacts_historical_bar_chart(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## cumul_contacts_historical_bar_chart_relative
# ~~~~ cumul_contacts_historical_bar_chart_relative ----
output$cumul_contacts_historical_bar_chart_relative <-
renderHighchart({
req(input$select_date_of_review)
cumul_contacts_historical_bar_chart_relative(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## cumul_contacts_historical_text
# ~~~~ cumul_contacts_historical_text ----
output$cumul_contacts_historical_text <-
renderUI({
req(input$select_date_of_review)
## use the same function.
cumul_contacts_historical_text(
contacts_df_long = read_file_filtered_reactive()
)
})
#' # active_contacts_today
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ active_contacts_today --------------------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Below we call the contacts_per_admin_1 functions. These show the distribution
#' of contacts over admin level 1 and admin level 2.
#' ## active_contacts_today_row_title
# ~~~~ active_contacts_today_row_title ----
output$active_contacts_today_row_title <- renderUI({
req(input$select_date_of_review)
active_contacts_today_row_title(input$select_date_of_review)
})
#' ## active_contacts_today_table
# ~~~~ active_contacts_today_table ----
output$active_contacts_today_table <-
renderReactable({
req(input$select_date_of_review)
active_contacts_today_table(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## active_contacts_today_sunburst_plot
# ~~~~ active_contacts_today_sunburst_plot ----
output$active_contacts_today_sunburst_plot <-
renderHighchart({
req(input$select_date_of_review)
active_contacts_today_sunburst_plot(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## active_contacts_today_bar_chart
# ~~~~ active_contacts_today_bar_chart ----
output$active_contacts_today_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
active_contacts_today_bar_chart(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## active_contacts_today_text
# ~~~~ active_contacts_today_text ----
output$active_contacts_today_text <-
renderUI({
req(input$select_date_of_review)
active_contacts_today_text(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' # active_contacts_historical
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ active_contacts_historical -----------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Functions showing how many contacts were under surveillance at each time point,
#' segregated by region.
#' ## active_contacts_historical_row_title
# ~~~~ active_contacts_historical_row_title ----
output$active_contacts_historical_row_title <- renderUI({
req(input$select_date_of_review)
active_contacts_historical_row_title()
})
#' ## active_contacts_historical_bar_chart
# ~~~~ active_contacts_historical_bar_chart ----
output$active_contacts_historical_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
active_contacts_historical_bar_chart(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## active_contacts_historical_bar_chart_relative
# ~~~~ active_contacts_historical_bar_chart_relative ----
output$active_contacts_historical_bar_chart_relative <-
renderHighchart({
req(input$select_date_of_review)
active_contacts_historical_bar_chart_relative(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' ## active_contacts_historical_text
# ~~~~ active_contacts_historical_text ----
output$active_contacts_historical_text <-
renderUI({
req(input$select_date_of_review)
active_contacts_historical_text(
contacts_df_long = read_file_filtered_reactive(),
todays_date = input$select_date_of_review
)
})
#' # contacts_per_case
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# ~ contacts_per_case -----------
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#' Functions that output the number of contacts linked to each case
#' At the moment (May 13, 2021), the Go.Data app version has no information for this column.
#' ## total_contacts_per_case_donut_plot
# ~~~~ total_contacts_per_case_donut_plot ----
output$total_contacts_per_case_donut_plot <-
renderHighchart({
req(input$select_date_of_review)
total_contacts_per_case_donut_plot(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## total_contacts_per_case_table
# ~~~~ total_contacts_per_case_table ----
output$total_contacts_per_case_table <-
renderUI({
req(input$select_date_of_review)
total_contacts_per_case_table(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## total_contacts_per_case_bar_chart
# ~~~~ total_contacts_per_case_bar_chart ----
output$total_contacts_per_case_bar_chart <-
renderHighchart({
req(input$select_date_of_review)
total_contacts_per_case_bar_chart(
contacts_df_long = read_file_filtered_reactive()
)
})
#' ## total_contacts_per_case_text
# ~~~~ total_contacts_per_case_text ----
output$total_contacts_per_case_text <-
renderUI({
req(input$select_date_of_review)