-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.Rmd
3827 lines (3048 loc) · 189 KB
/
index.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
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: Simulation
author: '<a href="https://github.com/pablobernabeu/Experimental-data-simulation/" target="_blank"><button class="button-version">v `r app_version = read.delim("https://raw.githubusercontent.com/pablobernabeu/Experimental-data-simulation/master/version_number", header = FALSE)[1,1]; sprintf("%.1f", app_version) # Version number can be updated at https://github.com/pablobernabeu/Experimental-data-simulation/blob/master/version_number`</button></a>'
output:
flexdashboard::flex_dashboard:
theme: 'spacelab'
orientation: columns
vertical_layout: scroll
favicon: https://raw.githubusercontent.com/pablobernabeu/Experimental-data-simulation/master/Royalty-free%20from%20www.needpix.com.png
runtime: shiny
---
```{r setup, include = FALSE}
library(dplyr)
library(DT)
library(flexdashboard)
library(htmltools)
library(knitr)
library(ngram)
library(purrr)
library(shiny)
library(stringr)
library(tidyr)
knitr::opts_chunk$set(echo = FALSE, message = FALSE, warning = FALSE, error = FALSE)
```
<!-- Adjust website settings -->
<head>
<style type="text/css">
<!-- Tabs format -->
/* tab, general */
ul.nav.navbar-nav.navbar-left a {
color: white;
background-color: none;
border-bottom: none;
}
/* tab hovered over */
ul.nav.navbar-nav.navbar-left a:hover {
color: white;
background-color: #34507D;
border-bottom: none;
text-shadow: none;
}
/* active tab */
ul.nav.navbar-nav.navbar-left li.active a {
color: white;
font-weight: bold;
background-color: #5472A3;
border-bottom: 3px solid;
text-shadow: none;
}
/* visited links in inactive tabs */
ul.nav.navbar-nav.navbar-left a:visited {
color: white;
font-weight: bold;
background-color: #5472A3;
border-bottom: none;
text-shadow: none;
}
/* 'Data set' tab, general */
#navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9) > a {
font-weight: bold;
}
/* 'Data set' tab, hovered over */
#navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9) > a:hover {
color: black;
background-color: #F0DFD0;
}
/* 'Data set' tab, active */
#navbar > ul.nav.navbar-nav.navbar-left > li:nth-child(9).active > a {
color: black;
background-color: #F0DFD0;
}
<!-- Fonts format -->
body{ /* Normal */
font-size: 16px;
}
td { /* Table */
font-size: 14px;
}
h1.title {
font-size: 38px;
font-weight: bold;
color: #28002E
}
h1 { /* Header 1 */
font-size: 28px;
font-weight: bold;
color: #28002E
}
h2 { /* Header 2 */
font-size: 22px;
font-weight: bold;
color: #28002E
}
h3 { /* Header 3 */
font-size: 18px;
font-weight: bold;
}
h4 { /* Header 4 */
font-size: 16px;
}
h5 { /* Header 5 */
font-size: 15px;
}
h6 { /* Header 6 */
font-size: 14px;
}
code.r{ /* Code block */
font-size: 22px;
}
pre { /* Code-formatted output */
font-size: 14px;
padding-top: 2px;
padding-bottom: 2px;
margin-top: -15px;
margin-bottom: 18px;
}
/* Input fields */
.shiny-bound-input {
font-size: 16px;
color: #2D5054;
}
/* Change error messages */
.shiny-output-error{
visibility: hidden;
padding-bottom: 10px;
}
.shiny-output-error:after{
content: 'Awaiting appropriate inputs or loading data.';
visibility: visible; color: #377277; font-size: 14px;
padding-bottom: 20px; margin-bottom: 20px;
}
/* Format buttons */
.button-version {
background-color: #FCF5F5;
opacity: 0.2;
border: none;
color: black;
font-weight: bold;
padding: 0px 4px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 10px;
margin: 0px 0px;
cursor: pointer;
border-radius: 12px;
}
.button-version:hover {
opacity: 1;
}
.button-samplesize {
background-color: #474A67;
border: none;
padding: 3px 9px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
margin: 0px 3px;
cursor: pointer;
border-radius: 12px;
}
.button-samplesize:hover {
background-color: #1B1B20;
}
.button-parameters-download {
border: 1px solid black;
background-color: #F4F9F9;
color: black;
padding: 3px 6px;
cursor: pointer;
border-color: #E4ECED;
color: black;
}
.button-parameters-download:hover {
background: #E9F2F2;
color: black;
}
/* Format the 'Multiply N' input field */
#multiply_N.form-control.shiny-bound-input {
padding-left: 20px;
padding-top: 8px;
padding-bottom: 8px;
font-size: 150%;
color: #932323;
letter-spacing: 4px;
}
</style>
<!-- Load Bootstrap libraries for icons -->
<link rel='stylesheet' href='https://use.fontawesome.com/releases/v5.7.0/css/all.css' integrity='sha384-lZN37f5QGtY3VHgisS14W3ExzMWZxybE1SJSEsQp9S+oqd12jhcu+A56Ebc1zFSJ' crossorigin='anonymous'>
<!-- Javascript function to enable a hovering tooltip -->
<script>
$(document).ready(function(){
$('[data-toggle="tooltip1"]').tooltip();
});
</script>
////// Tooltip css styling
$("#message").css({
'font-size':'2px'
});
</head>
<i class="fas fa-info-circle" aria-hidden="true"></i> Home {style="background-color: #FEFEFE; data-width: 100%; width: 900px; margin: 0 auto;"}
=======================================================================
Column {style='padding-top:30px;'}
-----------------------------------------------------------------------
### <span style='font-size:23px;'> **Web application for the simulation of experimental data**</span>
<div style = "padding-top: 5px; padding-left: 60px; padding-right: 60px; font-size: 16px; line-height: 1.6;">
<div style='text-align:right; margin-bottom: -30px;'>
<a href="http://creativecommons.org/licenses/by/4.0/" target="_blank" rel="Attribution licence" style="color:#CEC7BF; font-size:13px;"> Licence <img style="border-width:0;" src="https://i.creativecommons.org/l/by/4.0/80x15.png" alt="Creative Commons License"></img> </a>
</div>
<div style = 'font-size: 20px; color: #614064; padding-top: 10px; padding-bottom: 10px;'><i class="fas fa-chalkboard-teacher fa-xs" aria-hidden="true"></i> <i class="fas fa-university fa-xs" aria-hidden="true"></i> Purposes </div>
This open-source, R-based web application is suitable for educational and research purposes in experimental and quantitative sciences. It allows the **creation of varied data sets with specified structures, such as between-group and within-participant variables, that can be categorical or continuous.** These parameters can be set throughout the various tabs (sections) from the top menu. In the last tab, the data set can be downloaded. The benefits of this application include time-saving and flexibility in the control of parameters.
<h3>Guidelines</h3>
General guidelines include the following:
- **In the names of variables**, it's recommended only to use alphanumeric characters and underscore signs. The latter can be used to separate characters or words (e.g., *variable_name*). Different names should be used for each variable.
- **In the levels of categorical variables**, alphanumeric, special characters and spaces are allowed.
- **In numeric fields** (e.g., 'Mean', 'Standard deviation', 'Relative probability [0, 1]'), only numbers and decimal points are allowed.
- **As the data set increases**, so does the processing time.
More specific guidelines are available in each section.
<div style='padding-top:8px; padding-bottom:11px; color:#665F5F;'> Screenshot of the *Dependent* tab ([view larger](https://github.com/pablobernabeu/Experimental-data-simulation/raw/master/Screenshot.png){target='_blank'}) </div>
<img style="max-width: 750px; display: block; margin-left: auto; margin-right: auto; padding-bottom: 20px;" src="https://github.com/pablobernabeu/Experimental-data-simulation/raw/master/Screenshot.png" />
<h3>Rounding</h3>
Below, you can select the **number of decimal places** to be kept in any continuous variables that you create.
```{r}
numericInput('rounding', NULL, 3, min = 1, width = '60px')
```
<br>
<h3>Ensuring reproducibility of simulated data</h3>
Reproducing a simulation requires three pieces of data: the seed number, the parameter list and the final data set. After creating the variables wanted, make sure to download the parameter list and the final data set in the [last tab](#data-set). The seed number will be part of the names of the downloaded files.
A seed number is a code that allows the reproducibility of any data involving random generation. This applies to any variables created in the *Individual* tab or in the *Dependent* tab. The number is shown below, where you can change it to any integer number up to ±`r .Machine$integer.max`.
```{r}
tags$style(type = 'text/css',
'#seed.form-control.shiny-bound-input {padding-left:40px; padding-top:8px; padding-bottom:8px; font-size:150%; color:#206B90; letter-spacing:6px;}')
numericInput('seed', NULL, sample(1:99999, 1), step = 1, min = -.Machine$integer.max, max = .Machine$integer.max)
## Important notes about the seed ##
# The seed from input$seed must be set right before any random sampling function, such as rnorm() or rbinom(),
# using set.seed(input$seed).
# To avoid creating systematic patterns across variables, which would limit the use of having different
# variables (e.g., the correlations among continuous variables would be 1), each seed number must be in
# turn multiplied by a different number. These multiplication factors have been sequentially assigned,
# beginning from the Independent Categorical 2 variable (multiplication factor = 1) all the way down to
# the Dependent Continuous 8 variable (multiplication factor = 32). These numbers cannot be set using a
# function-based random number (e.g., using the 'sample()' function) because that would render the seed
# number useless, due to the crossing of random numbers.
```
<br>
<h3>Reference</h3>
Bernabeu, P., & Lynott, D. (2020). *Web application for the simulation of experimental data* (Version `r sprintf("%.1f", app_version)`). [https://github.com/pablobernabeu/Experimental-data-simulation/](https://github.com/pablobernabeu/Experimental-data-simulation/){target='_blank'}
<h3>Code</h3>
This web application was developed in [R](https://www.r-project.org/about.html){target='_blank'} (R Core Team, 2020). The code is [available on Github](https://github.com/pablobernabeu/Experimental-data-simulation){target='_blank'}, where contributions may be made. The initial code for this application was influenced by Section 5.7 ([*Simulating data for multi-factor designs*](https://crumplab.github.io/programmingforpsych/simulating-and-analyzing-data-in-r.html#simulating-data-for-multi-factor-designs){target='_blank'}) in Crump (2017). The R packages used include 'dplyr' (Wickham, François, Henry, & Müller, 2018), 'DT' (Xie, 2020), 'flexdashboard' (Iannone, Allaire, & Borges, 2020), 'shiny' (Chang, Cheng, Allaire, Xie, & McPherson, 2020) and 'stringr' (Wickham, 2019).
<br>
<h3>Acknowledgements</h3>
Thank you to RStudio for the free hosting server used by this application, [shinyapps.io](https://www.shinyapps.io/){target='_blank'}.
<h3>References</h3>
<div style = "text-indent:-1.5em; margin-left:1.5em;">
Chang, W., Cheng, J., Allaire, J., Xie, Y., & McPherson, J. (2020). shiny: Web Application Framework for R. R package version 1.4.0. Available at [http://CRAN.R-project.org/package=shiny](http://CRAN.R-project.org/package=shiny){target='_blank'}.
Crump, M. J. C. (2017). Programming for Psychologists: Data Creation and Analysis (Version 1.1). [https://crumplab.github.io/programmingforpsych/](https://crumplab.github.io/programmingforpsych/){target='_blank'}.
Iannone, R., Allaire, J. J., & Borges, B. (2020). Flexdashboard: R Markdown Format for Flexible Dashboards. [http://rmarkdown.rstudio.com/flexdashboard](http://rmarkdown.rstudio.com/flexdashboard){target='_blank'}.
R Core Team (2020). R: A language and environment for statistical computing. R Foundation for Statistical Computing, Vienna, Austria. URL [https://www.R-project.org/](https://www.R-project.org/){target='_blank'}.
Wickham, H. (2019). stringr: Simple, Consistent Wrappers for Common String Operations. R package version 1.4.0. [https://CRAN.R-project.org/package=stringr](https://CRAN.R-project.org/package=stringr){target='_blank'}.
Wickham, H., François, R., Henry, L., & Müller, K. (2018). dplyr: A Grammar of Data Manipulation. R package version 0.7.6. [https://CRAN.R-project.org/package=dplyr](https://CRAN.R-project.org/package=dplyr){target='_blank'}.
Xie, Y. (2020). DT: A Wrapper of the JavaScript Library "DataTables". R package version 0.14. Available at [https://CRAN.R-project.org/package=DT](https://CRAN.R-project.org/package=DT){target='_blank'}.
</div>
<h3>Contact</h3>
To submit any questions or feedback, please post a [GitHub issue](https://github.com/pablobernabeu/Experimental-data-simulation/issues){target='_blank'}, or email Pablo Bernabeu at [p.bernabeu@lancaster.ac.uk](mailto:p.bernabeu@lancaster.ac.uk){target='_blank'}.
<br>
<br>
</div>
Groups
=======================================================================
Column {style="margin-top:20px"}
-----------------------------------------------------------------------
### <span style='font-size:18px; color:#4D4F54;'> Groups and number of participants per group </span>
<br>
```{r}
groups_structure =
reactive({
x = final_dataset() %>%
# Remove all columns except groups
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
# This first bit displays number of observations per cell ('n')
group_by(across(any_of(
final_dataset() %>% select(-input$name_Participant_column) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
))) %>% tally %>%
# Merge the previous basic structure with the columns that are relevant now
merge(
final_dataset() %>%
# Remove all columns except groups and those variables created inside this tab
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
group_by(across(any_of(
final_dataset() %>%
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
))) %>% tally %>%
# Order columns in standard order, which is important for the setting of parameters within factor levels
select(any_of(c(
input$name_Participant_column,
input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8
))) %>%
# Remove duplicate rows
unique()
)
})
renderDT({
datatable(groups_structure(), class = 'nowrap compact cell-border', selection = 'none',
options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE,
pageLength = nrow(groups_structure())),
# Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758)
callback = JS(c(
"table.on('draw.dt', function(){",
" var PageInfo = table.page.info();",
" table.column(0, {page: 'current'}).nodes().each(function(cell,i){",
" cell.innerHTML = i + 1 + PageInfo.start;",
" });",
"})"
))) %>%
formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8')
})
```
Column {style="margin-top:20px"}
-----------------------------------------------------------------------
### <span style='font-weight:bold; font-size:15px; color:#0E6D00;'>Between-group 1</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup1', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group1', NULL, placeholder = 'Level 1')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group2', NULL, placeholder = 'Level 2')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group3', NULL, placeholder = 'Level 3')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group4', NULL, placeholder = 'Level 4')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group5', NULL, placeholder = 'Level 5')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group6', NULL, placeholder = 'Level 6')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group7', NULL, placeholder = 'Level 7')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group8', NULL, placeholder = 'Level 8')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group9', NULL, placeholder = 'Level 9')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup1_Group10', NULL, placeholder = 'Level 10')
```
Column {style="margin-top:20px"}
-----------------------------------------------------------------------
### <span style='font-weight:bold; font-size:15px; color:#001AB3;'>Between-group 2</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup2', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group1', NULL, placeholder = 'Level 1')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group2', NULL, placeholder = 'Level 2')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group3', NULL, placeholder = 'Level 3')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group4', NULL, placeholder = 'Level 4')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group5', NULL, placeholder = 'Level 5')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group6', NULL, placeholder = 'Level 6')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group7', NULL, placeholder = 'Level 7')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group8', NULL, placeholder = 'Level 8')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group9', NULL, placeholder = 'Level 9')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup2_Group10', NULL, placeholder = 'Level 10')
```
Column {style="margin-top:20px"}
-----------------------------------------------------------------------
### <span style='font-weight:bold; font-size:15px; color:#B32600;'>Between-group 3</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_BetweenGroup3', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group1', NULL, placeholder = 'Level 1')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group2', NULL, placeholder = 'Level 2')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group3', NULL, placeholder = 'Level 3')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group4', NULL, placeholder = 'Level 4')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group5', NULL, placeholder = 'Level 5')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group6', NULL, placeholder = 'Level 6')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group7', NULL, placeholder = 'Level 7')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group8', NULL, placeholder = 'Level 8')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group9', NULL, placeholder = 'Level 9')
textAreaInput(height = '45px', resize = 'vertical', 'BetweenGroup3_Group10', NULL, placeholder = 'Level 10')
```
Individual
=======================================================================
Column {style="margin-top:20px; padding-top:10px; max-width:700px"}
-----------------------------------------------------------------------
### <span style='font-size:18px; color:#4D4F54;'> **Groups structure to guide parameter setting**</span>
<br>
```{r}
Individual_factorial_structure =
reactive({
x = final_dataset() %>%
# Remove all columns except groups
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
# This first bit displays number of observations per cell ('n')
group_by(across(any_of(
final_dataset() %>% select(-input$name_Participant_column) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
))) %>% tally %>%
# Merge the previous basic structure with the columns that are relevant now
merge(
final_dataset() %>%
# Remove all columns except groups and those variables created inside this tab
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
group_by(across(any_of(
final_dataset() %>%
select(-any_of(c(input$name_Participant_column,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2,
input$name_WithinParticipant3, input$name_WithinParticipant4,
input$name_WithinParticipant5, input$name_WithinParticipant6,
input$name_WithinParticipant7, input$name_WithinParticipant8,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8))) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
))) %>% tally %>%
# Order columns in standard order, which is important for the setting of parameters within factor levels
select(any_of(c(
input$name_Participant_column,
input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8,
input$name_WithinParticipant1, input$name_WithinParticipant2, input$name_WithinParticipant3,
input$name_Trial_column, input$name_Extra_nested_column,
input$name_Categorical_Dependent1, input$name_Categorical_Dependent2,
input$name_Categorical_Dependent3, input$name_Categorical_Dependent4,
input$name_Categorical_Dependent5, input$name_Categorical_Dependent6,
input$name_Categorical_Dependent7, input$name_Categorical_Dependent8,
input$name_Continuous_Dependent1, input$name_Continuous_Dependent2,
input$name_Continuous_Dependent3, input$name_Continuous_Dependent4,
input$name_Continuous_Dependent5, input$name_Continuous_Dependent6,
input$name_Continuous_Dependent7, input$name_Continuous_Dependent8
))) %>%
# Remove duplicate rows
unique()
)
})
renderDT({
datatable(Individual_factorial_structure(), class = 'nowrap compact cell-border', selection = 'none',
options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE,
pageLength = nrow(Individual_factorial_structure())),
# Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758)
callback = JS(c(
"table.on('draw.dt', function(){",
" var PageInfo = table.page.info();",
" table.column(0, {page: 'current'}).nodes().each(function(cell,i){",
" cell.innerHTML = i + 1 + PageInfo.start;",
" });",
"})"
))) %>%
formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8')
})
```
<br>
<div style = 'padding-left: 40px; padding-right: 40px; padding-top: 15px; padding-bottom: 20px; background-color: #FEFEFE; font-size: 16px; line-height: 1.6;'>
The parameters for the dependent variables may be set generally for the whole data set. However, the parameters may also be adjusted by group ([tab](#groups)), if any groups have been created. Where any groups exist, they will constitute a factorial structure that will be displayed in the table above. Each row corresponds to a *cell* in that structure.
**Categorical variables.** This is a pseudorandom variable. Thus, it differs from *Groups* in that the categories are assigned to each cell following a probability input entered by the user (programming detail: using `rbinom()`). This input can range from 0 to 1. Values toward 0 increase the proportions of levels entered first, and values toward 1 increase the levels entered last. Where any groups exist (created in the Groups tab), to adjust the frequency of each level in the factors below per group, multiple probability values may be entered, separated by commas, each corresponding to a group. For instance, with four groups, the levels of a categorical independent variable could be entered as 'A, B, C', and the probabilities as $.2, .8, .4, .7$. This would mean that the most frequent level in Groups 1 to 4, respectively, would be A, C, B, and B. This variable does not add to the general factorial structure, unlike *Groups*.
**Continuous variables.** Where any groups exist (created in the Groups tab), to adjust the means and standard deviations for each group, multiple values may be entered, separated by commas, each corresponding to a group. For instance, with four groups, the means could be entered as $34, 543, 657, 123$, and the standard deviations as $10, 20, 25, 5$.
Since both of these variables use randomisation, the user's parameters will be more closely approached with larger samples ([adjust](#sample)). The overall summary, including the dependent variables, is shown below.
</div>
### **Summary including any individual variables** ([more summary options](#summary))
```{r}
factorial_structure_with_individual_variables =
reactive({
x = final_dataset() %>%
# Remove all columns except groups and those variables created inside this tab
select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>%
# This first bit displays number of observations per cell ('n')
group_by(across(any_of(
final_dataset() %>%
select(-any_of(c(input$name_Participant_column))) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
))) %>% tally %>%
# Merge the previous basic structure with the columns that are relevant now
merge(
final_dataset() %>%
# Remove all columns except groups and those variables created inside this tab
select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>%
group_by(across(any_of(
final_dataset() %>%
select(any_of(c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>%
select_if(~is.factor(.) | is.character(.)) %>% names()
)))
)
# If there aren't any numeric variables in the subset, just present the factors
if(!isTruthy(input$name_Continuous_Independent1)) {
summary =
x %>% group_by(across(any_of(
c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3,
input$name_Categorical_Independent1, input$name_Categorical_Independent2,
input$name_Categorical_Independent3, input$name_Categorical_Independent4,
input$name_Categorical_Independent5, input$name_Categorical_Independent6,
input$name_Categorical_Independent7, input$name_Categorical_Independent8,
input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8)
)))
} else # If there are any numeric variables in the subset, summarise data across factors
summary =
x %>%
group_by(across(any_of(
c(input$name_BetweenGroup1, input$name_BetweenGroup2, input$name_BetweenGroup3)))) %>%
summarise(across(any_of(
final_dataset() %>%
select(any_of(c(input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>%
select_if(~is.numeric(.)) %>% names()),
list(Mean = mean, SD = sd)))
merge(x, summary) %>%
select(-any_of(c(input$name_Continuous_Independent1, input$name_Continuous_Independent2,
input$name_Continuous_Independent3, input$name_Continuous_Independent4,
input$name_Continuous_Independent5, input$name_Continuous_Independent6,
input$name_Continuous_Independent7, input$name_Continuous_Independent8))) %>%
unique %>%
# Round off numeric variables
mutate(across(where(is.numeric), round, input$rounding))
})
renderDT(
datatable(factorial_structure_with_individual_variables(), class = 'nowrap compact cell-border', selection = 'none',
options = list(order = list(1, 'asc'), dom = 'rt', scroller = TRUE, ordering = FALSE,
pageLength = nrow(factorial_structure_with_individual_variables())),
# Fixed row names (source: https://stackoverflow.com/questions/55115183/r-dt-datatable-not-retaining-row-index-counter-column-after-selecting-new-page-w/55125758#55125758)
callback = JS(c(
"table.on('draw.dt', function(){",
" var PageInfo = table.page.info();",
" table.column(0, {page: 'current'}).nodes().each(function(cell,i){",
" cell.innerHTML = i + 1 + PageInfo.start;",
" });",
"})"
))) %>%
formatStyle(0, Color = '#595143', backgroundColor = '#EFF1F8')
)
```
Column {style="margin-top:30px"}
-----------------------------------------------------------------------
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 1</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent1', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent1', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent1', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent1)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent1() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent1()) / sum(table(Categorical_Independent1())) * 100) %>%
round(digits = 2), '%', collapse = '\n') %>%
str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat()
cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n",
"\nSee summary table for proportions per cell.\n_")
}
})
```
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 2</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent2', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent2', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent2', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent2)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent2() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent2()) / sum(table(Categorical_Independent2())) * 100) %>%
round(digits = 2), '%', collapse = '\n') %>%
str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat()
cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n",
"\nSee summary table for proportions per cell.\n_")
}
})
```
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 3</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent3', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent3', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent3', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent3)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent3() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent3()) / sum(table(Categorical_Independent3())) * 100) %>%
round(digits = 2), '%', collapse = '\n') %>%
str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat()
cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n",
"\nSee summary table for proportions per cell.\n_")
}
})
```
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 4</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent4', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent4', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent4', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent4)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent4() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent4()) / sum(table(Categorical_Independent4())) * 100) %>%
round(digits = 2), '%', collapse = '\n') %>%
str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat()
cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n",
"\nSee summary table for proportions per cell.\n_")
}
})
```
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 5</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent5', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent5', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent5', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent5)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent5() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent5()) / sum(table(Categorical_Independent5())) * 100) %>%
round(digits = 2), '%', collapse = '\n') %>%
str_replace_all(', ', ',') %>% str_replace_all(' ,', ',') %>% cat()
cat("\n\nNOTE: If any level has too little presence, consider\nslightly increasing the sample size in the Sample tab.\n",
"\nSee summary table for proportions per cell.\n_")
}
})
```
### <span style='font-weight:bold; font-size:15px; color:#BF4000;'>Categorical 6</span>
```{r}
textAreaInput(height = '45px', resize = 'vertical', 'name_Categorical_Independent6', NULL, placeholder = 'Variable name')
textAreaInput(height = '45px', resize = 'vertical', 'levels_Categorical_Independent6', NULL, placeholder = 'Levels')
textAreaInput(height = '45px', resize = 'vertical', 'probability_Categorical_Independent6', NULL, placeholder = 'Relative probability [0, 1] (per group)')
# The code below will display a summary of the variable designed by the user.
# Note that the variable is actually created and saved further below (see '# Create final data set').
reactive({
if(isTruthy(input$probability_Categorical_Independent6)) {
cat('\nProportion of each level\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n')
Categorical_Independent6() %>% levels() %>% trimws() %>%
paste0(., ': ', (table(Categorical_Independent6()) / sum(table(Categorical_Independent6())) * 100) %>%