-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.R
2035 lines (1899 loc) · 72.2 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
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
# create dir
dir.name <- 'www'
if (!dir.exists(dir.name)) {
dir.create(dir.name, recursive = TRUE, showWarnings = FALSE)
}
shiny::addResourcePath(prefix = "www", directoryPath = "www")
# create file with citations
grateful::cite_packages(
output = "file",
out.dir = file.path(getwd(), "www"),
out.format = "html",
pkgs = "All"
)
# copy favicon folder to the www dir
R.utils::copyDirectory(from = "favicon_io", to = file.path(dir.name, "favicon_io"))
# load libraries
library(dplyr)
library(htmltools)
# source all scripts
source("RCT-Diagnosis.R", local = TRUE) # diagnosis on original dataset and model
source("RCT-EffectSizes.R", local = TRUE) # effect size interpretation and reporting in text format
source("RCT-Figure2.R", local = TRUE) # numeric variables, plot of descriptive analysis (mean and CI)
source("RCT-NA.R", local = TRUE) # to convert specific values to NA
source("RCT-Report.R", local = TRUE) # report the statistical analysis plan in text format
source("RCT-Table1.R", local = TRUE) # numeric and categorical variables, descriptive analysis, between-factor
source("RCT-Table2a.R", local = TRUE) # numeric variables, linear mixed model analysis, between- AND within-factor WITH baseline adjustment
source("RCT-Table2b.R", local = TRUE) # numeric variables, linear mixed model analysis, between- AND within-factor WITHOUT baseline adjustment
source("RCT-Table3.R", local = TRUE) # ordinal variables, ridit analysis, ONLY within-factor
# use this code to debug
# rsconnect::showLogs()
ui <- shiny::fluidPage(
rintrojs::introjsUI(),
# add custom CSS to justify
tags$style('ul.nav-pills{display: flex !important;justify-content: center !important;}'),
# add favicon
shiny::tags$head(
shiny::tags$link(rel = "shortcut icon", href = "www/favicon_io/favicon.ico"),
shiny::tags$link(rel = "shortcut icon", href = "www/favicon_io/android-chrome-192x192.png"),
shiny::tags$link(rel = "shortcut icon", href = "www/favicon_io/android-chrome-512x512.png"),
shiny::tags$link(rel = "apple-touch-icon", href = "www/favicon_io/apple-touch-icon.png"),
shiny::tags$link(rel = "icon", href = "www/favicon_io/favicon-16x16.png"),
shiny::tags$link(rel = "icon", href = "www/favicon_io/favicon-32x32.png"),
shiny::tags$link(rel = "shortcut icon", href = "www/favicon_io/favicon.ico"),
),
# add font awesome
tags$head(
tags$link(rel = "stylesheet", href = "https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css")
),
# use shinythemes
theme = shinythemes::shinytheme("flatly"),
# use shinyjs
shinyjs::useShinyjs(),
# status bar
shinybusy::add_busy_bar(color = "#FF0000"),
# Application title
shiny::titlePanel(
list(
fontawesome::fa("users"),
fontawesome::fa("shuffle"),
fontawesome::fa("users"),
shiny::HTML("<strong>RCTapp</strong>")
),
windowTitle = "RCTapp | Randomized Clinical Trial"
),
shiny::HTML(
"<a href=\"https://doi.org/10.5281/zenodo.13848815\" style=\"vertical-align:middle;\"><img src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.13848815.svg\" alt=\"DOI\" style=\"vertical-align:top;\"></a>"
),
shiny::br(),
shiny::br(),
# change color of fileInput button
tags$head(tags$style(
shiny::HTML(".btn-file {background-color: #2C3E50;}")
)),
# Main panel for displaying outputs ----
shiny::tabsetPanel(
id = "tabs",
type = "tabs",
shiny::tabPanel(
title = list(fontawesome::fa("database"), "Data"),
# split panel into 2 columns
shiny::fluidRow(
shiny::column(
3,
shiny::br(),
shiny::wellPanel(
shiny::fluidRow(
shiny::column(
12,
shiny::actionButton(
inputId = "guide1",
icon = shiny::icon("info-circle"),
label = shiny::HTML("<strong>Study design</strong>"),
style = "color: black; background-color: transparent; border-color: transparent;"
),
),
style = "text-align:center;"
),
shiny::br(),
shiny::fluidRow(
shiny::column(
9,
# input Excel file data
shiny::fileInput(
inputId = "xlsxFile",
label = NULL,
multiple = FALSE,
buttonLabel = list(fontawesome::fa("file-excel"), "Upload"),
accept = c(".xlsx"),
width = "100%",
placeholder = "XLSX file"
),
style = "text-align:center;"
),
shiny::column(
3,
shiny::tags$a(
id = "restart",
class = "btn btn-primary",
href = "javascript:history.go(0)",
shiny::HTML('<i class="fa fa-refresh fa-1x"></i>'),
title = "restart",
style = "color:white; border-color:white; border-radius:100%;"
),
style = "text-align:center;"
),
),
rintrojs::introBox(
# add checkbox for between-subject factors (BGF)
shinyWidgets::virtualSelectInput(
inputId = "BGF",
label = "Treatment groups",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = FALSE,
width = "100%"
),
data.step = 1,
data.intro = ""
),
rintrojs::introBox(
# number of endpoits
shiny::numericInput(
inputId = "endpointN",
label = "Endpoints",
value = 2,
min = 2,
step = 1,
width = "100%"
),
data.step = 2,
data.intro = ""
),
rintrojs::introBox(
# show text for endpoint
shiny::textInput(
inputId = "endpointValues",
label = "Endpoint value (csv)",
value = "0,1",
width = "100%"
),
data.step = 3,
data.intro = ""
),
shiny::fluidRow(
shiny::column(
6,
rintrojs::introBox(
# alpha level for statistical significance
shiny::numericInput(
inputId = "alpha",
label = "Alpha level",
value = 0.05,
min = 0.001,
max = 0.999,
step = 0.001,
width = "100%"
),
data.step = 4,
data.intro = ""
),
),
shiny::column(
6,
rintrojs::introBox(
# effect size interpretation rules
shinyWidgets::virtualSelectInput(
inputId = "effectSize",
label = "Effect size",
choices = c("Cohen (1988)", "Gignac (2016)", "Sawilowsky (2009)", "Lovakov (2021)"),
selected = "Cohen (1988)",
showValueAsTags = TRUE,
search = FALSE,
multiple = FALSE,
width = "100%"
),
data.step = 5,
data.intro = ""
),
),
),
),
shiny::wellPanel(
rintrojs::introBox(
# show text input to change treatment group names
shiny::textInput(
inputId = "treatmentNames",
label = "Treatment labels (csv)",
value = "Control,Intervention",
width = "100%"
),
data.step = 6,
data.intro = ""
),
rintrojs::introBox(
# show options for control group
shinyWidgets::virtualSelectInput(
inputId = "controlgroup",
label = "Control group",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = FALSE,
width = "100%"
),
data.step = 7,
data.intro = ""
),
rintrojs::introBox(
# show text for endpoint names
shiny::textInput(
inputId = "endpointNames",
label = "Endpoint labels (csv)",
value = "Baseline,Follow-up",
width = "100%"
),
data.step = 8,
data.intro = ""
),
),
),
shiny::column(
9,
shiny::br(),
shiny::wellPanel(
DT::DTOutput(outputId = "rawtable"),
),
),
),
),
shiny::tabPanel(
title = list(fontawesome::fa("list-check"), "Analysis"),
# split panel into 3 columns
shiny::fluidRow(
shiny::column(
4,
shiny::br(),
shiny::wellPanel(
shiny::fluidRow(
shiny::column(
9,
shiny::actionButton(
inputId = "guide2",
icon = shiny::icon("info-circle"),
label = shiny::HTML("<strong>Participants' characteristics</strong>"),
style = "color: black; background-color: transparent; border-color: transparent;"
),
),
shiny::column(
3,
rintrojs::introBox(
# add action button to run table 1
shiny::actionButton(
inputId = "runTable1",
icon = shiny::icon("play"),
label = "Table 1",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
data.step = 4,
data.intro = ""
),
),
style = "text-align:center;"
),
shiny::br(),
rintrojs::introBox(
# add checkbox for baseline variables (BV)
shinyWidgets::virtualSelectInput(
inputId = "BV",
label = "Baseline variables (all types)",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE,
width = "100%"
),
data.step = 1,
data.intro = ""
),
rintrojs::introBox(
# add checkbox for show p-value
shiny::checkboxInput(
inputId = "showPvalue",
label = "Show P-value",
value = FALSE,
width = "100%"
),
data.step = 2,
data.intro = ""
),
),
shiny::wellPanel(
rintrojs::introBox(
# show maxlevels for between-subject factors
shiny::numericInput(
inputId = "maxlevels",
label = "Max levels (categorical variables only)",
value = 5,
min = 1,
max = 10,
step = 1,
width = "100%"
),
data.step = 3,
data.intro = ""
),
),
),
shiny::column(
4,
shiny::br(),
shiny::wellPanel(
shiny::fluidRow(
shiny::column(
6,
shiny::actionButton(
inputId = "guide3",
icon = shiny::icon("info-circle"),
label = shiny::HTML("<strong>Numerical outcome</strong>"),
style = "color: black; background-color: transparent; border-color: transparent;"
),
),
shiny::column(
3,
rintrojs::introBox(
# add button to run analysis
shiny::actionButton(
inputId = "runTable2",
icon = shiny::icon("play"),
label = "Table 2",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
data.step = 8,
data.intro = ""
),
),
shiny::column(
3,
rintrojs::introBox(
# add button to run analysis
shiny::actionButton(
inputId = "runFigure2",
icon = shiny::icon("play"),
label = "Figure 2",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
data.step = 9,
data.intro = ""
),
),
style = "text-align:center;"
),
shiny::br(),
rintrojs::introBox(
# add checkbox for outcome variables (OV)
shinyWidgets::virtualSelectInput(
inputId = "OV",
label = "Outcome variable (all columns)",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE,
width = "100%"
),
data.step = 1,
data.intro = ""
),
rintrojs::introBox(
# show checkbox for indicating outcomes has baseline data
shiny::checkboxInput(
inputId = "hasBaseline",
label = "Baseline data is available",
value = TRUE,
width = "100%"
),
data.step = 2,
data.intro = ""
),
rintrojs::introBox(
# add checkbox for covariates (COV)
shinyWidgets::virtualSelectInput(
inputId = "COV",
label = "Covariates",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE,
width = "100%"
),
data.step = 3,
data.intro = ""
),
shiny::fluidRow(
shiny::column(
8,
rintrojs::introBox(
# show options for missing data
shinyWidgets::virtualSelectInput(
inputId = "missing",
label = "Missing data imputation",
choices = c("Multiple imputation", "Mean imputation", "Complete cases"),
selected = "Multiple imputation",
showValueAsTags = TRUE,
search = TRUE,
multiple = FALSE,
width = "100%"
),
data.step = 4,
data.intro = ""
),
),
shiny::column(
4,
rintrojs::introBox(
# number of resamples
shiny::numericInput(
inputId = "MICEresamples",
label = "Resamples",
value = 50,
min = 1,
max = 100,
step = 1,
width = "100%"
),
data.step = 5,
data.intro = ""
),
),
),
rintrojs::introBox(
# show options for regression diagnosis
shinyWidgets::virtualSelectInput(
inputId = "regressionDiag",
label = "Diagnosis",
choices = c(
"Scaled Residuals",
"Component-Plus-Residual",
"Variance Inflation Factor",
"Missing Data",
"Imputed Data",
"Convergence"
),
selected = c(
"Scaled Residuals",
"Component-Plus-Residual",
"Variance Inflation Factor",
"Missing Data",
"Imputed Data",
"Convergence"
),
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE,
width = "100%"
),
data.step = 6,
data.intro = ""
),
),
shiny::wellPanel(
rintrojs::introBox(
# show text input to change outcome name
shiny::textInput(
inputId = "OutcomeName",
label = "Outcome label",
value = "Outcome",
width = "100%"
),
data.step = 7,
data.intro = ""
),
rintrojs::introBox(
# options for legend
shinyWidgets::virtualSelectInput(
inputId = "legendOptions",
label = "Legend position",
choices = c(
"none",
"top",
"topleft",
"topright",
"bottom",
"bottomleft",
"bottomright",
"left",
"right",
"center"
),
selected = "top",
showValueAsTags = TRUE,
search = TRUE,
multiple = FALSE,
width = "100%"
),
data.step = 8,
data.intro = ""
),
),
),
shiny::column(
4,
shiny::br(),
shiny::wellPanel(
shiny::fluidRow(
shiny::column(
9,
shiny::actionButton(
inputId = "guide4",
icon = shiny::icon("info-circle"),
label = shiny::HTML("<strong>Ordinal outcome</strong>"),
style = "color: black; background-color: transparent; border-color: transparent;"
),
),
shiny::column(
3,
rintrojs::introBox(
# add button to run analysis
shiny::actionButton(
inputId = "runTable3",
icon = shiny::icon("play"),
label = "Table 3",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
data.step = 3,
data.intro = ""
),
),
style = "text-align:center;"
),
shiny::br(),
rintrojs::introBox(
# add checkbox for outcome variables (OV)
shinyWidgets::virtualSelectInput(
inputId = "OVRidit",
label = "Outcome variable (all columns)",
choices = NULL,
selected = NA,
showValueAsTags = TRUE,
search = TRUE,
multiple = TRUE,
width = "100%"
),
data.step = 1,
data.intro = ""
),
),
shiny::wellPanel(
shiny::br(),
rintrojs::introBox(
# show text input to change outcome name
shiny::textInput(
inputId = "OutcomeNameRidit",
label = "Outcome label",
value = "Outcome",
width = "100%"
),
data.step = 2,
data.intro = ""
),
),
),
),
),
# tab for reporting the statistical analysis plan
shiny::tabPanel(
title = list(fontawesome::fa("file-alt"), "Plan"),
shiny::wellPanel(
# show text output
shiny::htmlOutput("SAP"),
shiny::br(),
# download Word format
shiny::downloadButton(
outputId = "downloadSAP",
label = "Download SAP (.DOCX)",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
shiny::br(),
shiny::br(),
),
),
# tab for table 1 of results
shiny::tabPanel(
title = list(fontawesome::fa("table"), "Table 1"),
shiny::wellPanel(
# show table of results
DT::dataTableOutput("table1"),
shiny::br(),
# download Word format
shiny::downloadButton(
outputId = "downloadTable1",
label = "Download Table 1 (.DOCX)",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
shiny::br(),
shiny::br(),
),
),
# tab for table 2 of results
shiny::tabPanel(
title = list(fontawesome::fa("table"), "Table 2"),
shiny::wellPanel(
# show table of results
DT::dataTableOutput("table2"),
shiny::br(),
# show output text of table 2
shiny::htmlOutput("textTable2"),
# download Word format
shiny::br(),
shiny::downloadButton(
outputId = "downloadTable2",
label = "Download Table 2 (.DOCX)",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
shiny::br(),
shiny::br(),
),
),
# tab for plot of results
shiny::tabPanel(
title = list(fontawesome::fa("chart-line"), "Figure 2"),
shiny::wellPanel(
# show plot of results
shiny::plotOutput("plot"),
shiny::br(),
# download TIFF format
shiny::downloadButton(
outputId = "downloadFigure2",
label = "Download Figure 2 (.TIFF)",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
shiny::br(),
shiny::br(),
),
),
# tab for table 3 of results
shiny::tabPanel(
title = "Table 3",
icon = fontawesome::fa("table"),
shiny::wellPanel(
# show table of results
DT::dataTableOutput("table3"),
shiny::br(),
# download Word format
shiny::downloadButton(
outputId = "downloadTable3",
label = "Download Table 3 (.DOCX)",
style = "color: #FFFFFF; background-color: #2C3E50; border-color: #2C3E50; width: 100%;"
),
shiny::br(),
shiny::br(),
),
),
shiny::tabPanel(
title = list(fontawesome::fa("stethoscope"), "Diagnostics"),
shiny::wellPanel(
# add tab panel
shiny::tabsetPanel(
id = "diagTab",
type = "pills",
shiny::tabPanel(
title = "Scaled Residuals",
icon = fontawesome::fa("chart-column"),
shiny::br(),
# add plot
shiny::plotOutput("plotDiag3"),
shiny::br(),
# show output text from scaled residuals
shiny::htmlOutput("tableDiag3"),
),
shiny::tabPanel(
title = "Component-Plus-Residual",
icon = fontawesome::fa("table-columns"),
shiny::br(),
# add plot
shiny::plotOutput("plotDiag5")
),
shiny::tabPanel(
title = "Variance Inflation Factor",
icon = fontawesome::fa("table"),
shiny::br(),
# add table
shiny::tableOutput("tableDiag6")
),
shiny::tabPanel(
title = "Missing Data",
icon = fontawesome::fa("person-circle-question"),
shiny::br(),
# add plot
shiny::plotOutput("plotDiag1"),
shiny::br(),
# show output text of missing data
shiny::htmlOutput("tableDiag1"),
),
shiny::tabPanel(
title = "Imputed Data",
icon = fontawesome::fa("arrows-to-dot"),
shiny::br(),
# add plot
shiny::plotOutput("plotDiag2")
),
shiny::tabPanel(
title = "Convergence",
icon = fontawesome::fa("chart-line"),
shiny::br(),
# add plot
shiny::plotOutput("plotDiag4")
),
),
),
),
shiny::tabPanel(
title = list(fontawesome::fa("book-open"), "References"),
shiny::br(),
# session info text output
shiny::htmlOutput("gratrep")
),
shiny::tabPanel(
title = list(fontawesome::fa("file-lines"), "Publications"),
shiny::br(),
shiny::HTML(
"Castro, J., Correia, L., Donato, B. de S., Arruda, B., Agulhari, F., Pellegrini, M. J., Belache, F. T. C., de Souza, C. P., Fernandez, J., Nogueira, L. A. C., Reis, F. J. J., Ferreira, A. de S., & Meziat-Filho, N. (2022). Cognitive functional therapy compared with core exercise and manual therapy in patients with chronic low back pain: randomised controlled trial. In Pain (Vol. 163, Issue 12, pp. 2430–2437). Ovid Technologies (Wolters Kluwer Health). <a href=\"https://doi.org/10.1097/j.pain.0000000000002644 \">https://doi.org/10.1097/j.pain.0000000000002644</a>"
),
shiny::br(),
shiny::br(),
shiny::HTML(
"Avila, L., da Silva, M. D., Neves, M. L., Abreu, A. R., Fiuza, C. R., Fukusawa, L., de Sá Ferreira, A., & Meziat-Filho, N. (2023). Effectiveness of Cognitive Functional Therapy Versus Core Exercises and Manual Therapy in Patients With Chronic Low Back Pain After Spinal Surgery: Randomized Controlled Trial. In Physical Therapy (Vol. 104, Issue 1). Oxford University Press (OUP). <a https://doi.org/10.1093/ptj/pzad105 \">https://doi.org/10.1093/ptj/pzad105</a>"
),
shiny::br(),
shiny::br(),
shiny::HTML(
"de Lira MR, Meziat-Filho N, Zuelli Martins Silva G, et al Efficacy of cognitive functional therapy for pain intensity and disability in patients with non-specific chronic low back pain: a randomised sham-controlled trial British Journal of Sports Medicine Published Online First: 06 March 2025. <a https://doi.org/10.1136/bjsports-2024-109012 \">https://doi.org/10.1136/bjsports-2024-109012</a>"
),
shiny::br(),
),
shiny::tabPanel(
title = list(fontawesome::fa("people-group"), "Credits"),
shiny::br(),
shiny::HTML(
"<b>Arthur de Sá Ferreira, DSc</b> (Developer)"),
shiny::br(),
shiny::HTML(
'<a id="cy-effective-orcid-url" class="underline"
href="https://orcid.org/0000-0001-7014-2002"
target="orcid.widget" rel="me noopener noreferrer" style="vertical-align: top">
<img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" style="width: 1em; margin-inline-start: 0.5em" alt="ORCID iD icon"/>
https://orcid.org/0000-0001-7014-2002
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML(
"<b>Ney Meziat Filho, DSc</b> (Developer)"),
shiny::br(),
shiny::HTML(
'<a id="cy-effective-orcid-url" class="underline"
href="https://orcid.org/0000-0003-2794-7299"
target="orcid.widget" rel="me noopener noreferrer" style="vertical-align: top">
<img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" style="width: 1em; margin-inline-start: 0.5em" alt="ORCID iD icon"/>
https://orcid.org/0000-0003-2794-7299
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML(
"<b>Fabiana Terra Cunha, DSc</b> (Contributor)"),
shiny::br(),
shiny::HTML(
'<a id="cy-effective-orcid-url" class="underline"
href="https://orcid.org/0000-0002-2043-8494"
target="orcid.widget" rel="me noopener noreferrer" style="vertical-align: top">
<img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" style="width: 1em; margin-inline-start: 0.5em" alt="ORCID iD icon"/>
https://orcid.org/0000-0002-2043-8494
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML(
"<b>Jessica Fernandez, DSc</b> (Contributor)"),
shiny::br(),
shiny::HTML(
'<a id="cy-effective-orcid-url" class="underline"
href="https://orcid.org/0000-0003-0047-9659"
target="orcid.widget" rel="me noopener noreferrer" style="vertical-align: top">
<img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" style="width: 1em; margin-inline-start: 0.5em" alt="ORCID iD icon"/>
https://orcid.org/0000-0003-0047-9659
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML(
"<b>Julia Castro, DSc</b> (Contributor)"),
shiny::br(),
shiny::HTML(
'<a id="cy-effective-orcid-url" class="underline"
href="https://orcid.org/0000-0003-0511-5715"
target="orcid.widget" rel="me noopener noreferrer" style="vertical-align: top">
<img src="https://orcid.org/sites/default/files/images/orcid_16x16.png" style="width: 1em; margin-inline-start: 0.5em" alt="ORCID iD icon"/>
https://orcid.org/0000-0003-0511-5715
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML(
"<b>Centro Universitário Augusto Motta</b> (Affiliation) <br>
Programa de Pós-graduação em Ciências da Reabilitação <br>
Rio de Janeiro, RJ, Brazil"),
shiny::br(),
shiny::HTML(
'<a
href="https://ror.org/02ab1bc46"
style="vertical-align: top">
<img src="https://ror.org/assets/ror-logo-small-671ea83ad5060ad5c0c938809aab4731.png" style="width: 1em; margin-inline-start: 0.5em"/>
https://ror.org/02ab1bc46
</a>'
),
shiny::br(),
shiny::br(),
shiny::HTML("<b>License</b>"),
shiny::HTML(
"This work is licensed under an <a rel=\"license\" data-spdx=\"Apache-2.0\" href=\"https://www.apache.org/licenses/LICENSE-2.0\">Apache License 2.0</a>."
),
shiny::br(),
shiny::br(),
shiny::HTML("<b>Citation</b>"),
shiny::HTML(
"Ferreira, A. de S., & Meziat Filho, N. (2024). RCTapp. Zenodo. <a href=\"https://doi.org/10.5281/zenodo.13848815\" target=\"_blank\">https://doi.org/10.5281/zenodo.13848815</a>"
),
shiny::br(),
shiny::br(),
),
),
)
# Define server script
server <- function(input, output, session) {
# for multiple tabsets
guidelist <- shiny::reactive(data.table::data.table(
tab = c("guide1", "guide1", "guide1", "guide1", "guide1", "guide1", "guide1", "guide1",
"guide2", "guide2", "guide2", "guide2",
"guide3", "guide3", "guide3", "guide3", "guide3", "guide3", "guide3", "guide3", "guide3", "guide3",
"guide4", "guide4", "guide4"),
step = c(1,2,3,4,5,6,7,8,
1,2,3,4,
1,2,3,4,5,6,7,8,9,10,
1,2,3),
element = c("#BGF", "#endpointN", "#endpointValues", "#alpha", "#effectSize", "#treatmentNames", "#controlgroup", "#endpointNames",
"#BV", "#showPvalue", "#maxlevels", "#runTable1",
"#OV", "#hasBaseline", "#COV", "#missing", "#MICEresamples", "#regressionDiag", "#OutcomeName", "#legendOptions", "#runTable2", "#runFigure2",
"#OVRidit", "#OutcomeNameRidit", "#runTable3"),
intro = c("Select the between-group factor. The list of variables comprises all columns in your dataset.", "Select the number of endpoints, including the baseline.", "Report all the endpoints in the same time unit (e.g., days or months), starting baseline at 0. Use comma separated values.", "Select the pre-specified type-I error.", "Select the rule for interpreting Cohen's d.", "Edit the group labels. These labels appear in tables and figure, and as options to select the control group below. Use comma separated values.", "Select the control group. This group is used as reference for between-group comparisons.", "Edit the endpoint names. These labels appears in tables and figure. Use comma separated values.",
"Select the variables (all types included: numeric, ordinal, categorical) measured at baseline for between-group reporting.", "Check this box to report P-values for between-group baseline comparisons.", "Indicate the maximum number of levels for a variable to be considered as categorical.", "Run 'Table 1!' to get the sample's baseline summary.",
"Select the numeric outcome variable, one per endpoint. The number of selected columns must match the number of endpoint names and values.", "Check this box to indicate that baseline values are available. Alternatively, uncheck this box.", "Select the covariates (all types included: numeric, ordinal, categorical), if any.", "Select how to handle missing data in analysis.", "If multiple imputation is selected, indicate the number of resamples for the multiple imputation by chained equations.", "Select diagnostic analysis of missing data, model fit and multiple imputation, if any.", "Edit the outcome label. This label appears in tables and figure.", "Select the position of the plot legend, if any.", "Run 'Table 2!' to get the linear mixed model (interaction, between- and within-group comparisons) summary.", "Run 'Figure 2' to get the interaction plot for the linear mixed model.",
"Select the ordinal outcome variable, one per endpoint. The number of selected columns must match the number of endpoint names and values.", "Edit the outcome label. This label appears in table.", "Run 'Table 3' to get the summary of the Ridit analysis.")
))
# start introjs when button is pressed with custom options and events
shiny::observeEvent(
eventExpr = input$guide1,
handlerExpr = {
rintrojs::introjs(session,
options = list(
"showBullets"="false", "showProgress"="true",
"showStepNumbers"="false","nextLabel"="Next","prevLabel"="Previous","skipLabel"="",
steps=guidelist()[tab == "guide1"]
)
)
}
)
shiny::observeEvent(
eventExpr = input$guide2,
handlerExpr = {
rintrojs::introjs(session,
options = list(
"showBullets"="false", "showProgress"="true",
"showStepNumbers"="false","nextLabel"="Next","prevLabel"="Previous","skipLabel"="",
steps=guidelist()[tab == "guide2"]
)
)
}
)
shiny::observeEvent(
eventExpr = input$guide3,
handlerExpr = {
rintrojs::introjs(session,
options = list(
"showBullets"="false", "showProgress"="true",
"showStepNumbers"="false","nextLabel"="Next","prevLabel"="Previous","skipLabel"="",
steps=guidelist()[tab == "guide3"]
)
)
}
)
shiny::observeEvent(
eventExpr = input$guide4,
handlerExpr = {
rintrojs::introjs(session,
options = list(
"showBullets"="false", "showProgress"="true",
"showStepNumbers"="false","nextLabel"="Next","prevLabel"="Previous","skipLabel"="",
steps=guidelist()[tab == "guide4"]
)
)
}
)
# upload excel file ---------------------------------------------------------
values <- shiny::reactiveValues(upload_state = NULL)
shiny::observeEvent(input$xlsxFile, {
values$upload_state <- 'uploaded'
})
shiny::observeEvent(input$restart, {
values$upload_state <- 'restart'
})
# enable resamples if multiple imputation is differente from complete cases
shiny::observeEvent(input$missing, {
if (input$missing == "Multiple imputation") {
shinyjs::enable("MICEresamples")
} else {
shinyjs::disable("MICEresamples")
}
})
# create automatic endopoint names and values based on endpointN
shiny::observeEvent(input$endpointN, {
shiny::updateTextInput(session,
"endpointNames",
value = paste0("T", 1:input$endpointN, collapse = ","))
shiny::updateTextInput(session,
"endpointValues",
value = paste0(0:(input$endpointN - 1), collapse = ","))
})
shiny::observeEvent(input$BGF, {
shiny::req(rawdata())
shiny::req(input[["BGF"]])
# read file
rawdata <- readxl::read_xlsx(rawdata())
# remove empty columns
rawdata <- rawdata[, colSums(is.na(rawdata)) != nrow(rawdata)]
# remove empty rows
rawdata <- rawdata[rowSums(is.na(rawdata)) != ncol(rawdata), ]
# clean variable names
colnames(rawdata) <- janitor::make_clean_names(colnames(rawdata))
# clean NA values
rawdata <- as.NA(rawdata)
# update treatmentNames after number of levels from BGV
shiny::updateTextInput(
inputId = "treatmentNames",
value = paste0(unique(rawdata[[input[["BGF"]]]]), collapse = ",")
)
})