-
Notifications
You must be signed in to change notification settings - Fork 0
/
Preprocessing.html
2142 lines (2102 loc) · 289 KB
/
Preprocessing.html
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
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
<meta charset="utf-8">
<meta name="generator" content="quarto-1.2.335">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<meta name="dcterms.date" content="2023-04-25">
<title>Data Cleaning, Wrangling, and Exploration</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
width: 0.8em;
margin: 0 0.8em 0.2em -1.6em;
vertical-align: middle;
}
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { display: inline-block; line-height: 1.25; }
pre > code.sourceCode > span:empty { height: 1.2em; }
.sourceCode { overflow: visible; }
code.sourceCode > span { color: inherit; text-decoration: inherit; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
}
@media print {
pre > code.sourceCode { white-space: pre-wrap; }
pre > code.sourceCode > span { text-indent: -5em; padding-left: 5em; }
}
pre.numberSource code
{ counter-reset: source-line 0; }
pre.numberSource code > span
{ position: relative; left: -4em; counter-increment: source-line; }
pre.numberSource code > span > a:first-child::before
{ content: counter(source-line);
position: relative; left: -1em; text-align: right; vertical-align: baseline;
border: none; display: inline-block;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ }
@media screen {
pre > code.sourceCode > span > a:first-child::before { text-decoration: underline; }
}
code span.al { color: #ff0000; font-weight: bold; } /* Alert */
code span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #7d9029; } /* Attribute */
code span.bn { color: #40a070; } /* BaseN */
code span.bu { color: #008000; } /* BuiltIn */
code span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4070a0; } /* Char */
code span.cn { color: #880000; } /* Constant */
code span.co { color: #60a0b0; font-style: italic; } /* Comment */
code span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #ba2121; font-style: italic; } /* Documentation */
code span.dt { color: #902000; } /* DataType */
code span.dv { color: #40a070; } /* DecVal */
code span.er { color: #ff0000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #40a070; } /* Float */
code span.fu { color: #06287e; } /* Function */
code span.im { color: #008000; font-weight: bold; } /* Import */
code span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #007020; font-weight: bold; } /* Keyword */
code span.op { color: #666666; } /* Operator */
code span.ot { color: #007020; } /* Other */
code span.pp { color: #bc7a00; } /* Preprocessor */
code span.sc { color: #4070a0; } /* SpecialChar */
code span.ss { color: #bb6688; } /* SpecialString */
code span.st { color: #4070a0; } /* String */
code span.va { color: #19177c; } /* Variable */
code span.vs { color: #4070a0; } /* VerbatimString */
code span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
</style>
<script src="Preprocessing_files/libs/clipboard/clipboard.min.js"></script>
<script src="Preprocessing_files/libs/quarto-html/quarto.js"></script>
<script src="Preprocessing_files/libs/quarto-html/popper.min.js"></script>
<script src="Preprocessing_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="Preprocessing_files/libs/quarto-html/anchor.min.js"></script>
<link href="Preprocessing_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="Preprocessing_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="Preprocessing_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="Preprocessing_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="Preprocessing_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">
<link href="Preprocessing_files/libs/pagedtable-1.1/css/pagedtable.css" rel="stylesheet">
<script src="Preprocessing_files/libs/pagedtable-1.1/js/pagedtable.js"></script>
</head>
<body>
<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">
<div id="quarto-margin-sidebar" class="sidebar margin-sidebar">
<nav id="TOC" role="doc-toc" class="toc-active">
<h2 id="toc-title">Table of contents</h2>
<ul>
<li><a href="#load-files" id="toc-load-files" class="nav-link active" data-scroll-target="#load-files">Load files</a></li>
<li><a href="#examine-validation-scores" id="toc-examine-validation-scores" class="nav-link" data-scroll-target="#examine-validation-scores">Examine validation scores</a>
<ul class="collapse">
<li><a href="#get-higher-validation-score-for-participants-if-2-rounds-of-validation" id="toc-get-higher-validation-score-for-participants-if-2-rounds-of-validation" class="nav-link" data-scroll-target="#get-higher-validation-score-for-participants-if-2-rounds-of-validation">Get higher validation score for participants, if 2 rounds of validation</a></li>
<li><a href="#quick-calculation-what-if-we-were-to-use-validation-score-above-80-on-any-of-5-points" id="toc-quick-calculation-what-if-we-were-to-use-validation-score-above-80-on-any-of-5-points" class="nav-link" data-scroll-target="#quick-calculation-what-if-we-were-to-use-validation-score-above-80-on-any-of-5-points">Quick calculation: what if we were to use “validation score above 80% on any of 5 points”</a></li>
<li><a href="#subset-for-participants-who-passed-the-threshold" id="toc-subset-for-participants-who-passed-the-threshold" class="nav-link" data-scroll-target="#subset-for-participants-who-passed-the-threshold">Subset for participants who passed the threshold</a></li>
<li><a href="#descriptive-statistics-of-all-participants" id="toc-descriptive-statistics-of-all-participants" class="nav-link" data-scroll-target="#descriptive-statistics-of-all-participants">Descriptive statistics of all participants</a></li>
<li><a href="#histogram-and-density-curve-of-all-participants" id="toc-histogram-and-density-curve-of-all-participants" class="nav-link" data-scroll-target="#histogram-and-density-curve-of-all-participants">Histogram and density curve of all participants</a></li>
<li><a href="#box-and-whisker-plot-validation-scores-of-all-participants" id="toc-box-and-whisker-plot-validation-scores-of-all-participants" class="nav-link" data-scroll-target="#box-and-whisker-plot-validation-scores-of-all-participants">Box and whisker plot, validation scores of all participants</a></li>
<li><a href="#descriptive-statistics-for-each-validation-point" id="toc-descriptive-statistics-for-each-validation-point" class="nav-link" data-scroll-target="#descriptive-statistics-for-each-validation-point">Descriptive statistics for each validation point</a></li>
</ul></li>
<li><a href="#reaction-time-data" id="toc-reaction-time-data" class="nav-link" data-scroll-target="#reaction-time-data">Reaction time data</a>
<ul class="collapse">
<li><a href="#cleanup" id="toc-cleanup" class="nav-link" data-scroll-target="#cleanup">Cleanup</a></li>
<li><a href="#apply-exclusions-exclusion-3---2---1" id="toc-apply-exclusions-exclusion-3---2---1" class="nav-link" data-scroll-target="#apply-exclusions-exclusion-3---2---1">Apply exclusions (Exclusion 3 -> 2 -> 1)</a></li>
<li><a href="#exclusion-3" id="toc-exclusion-3" class="nav-link" data-scroll-target="#exclusion-3">Exclusion 3</a></li>
<li><a href="#exclusion-2" id="toc-exclusion-2" class="nav-link" data-scroll-target="#exclusion-2">Exclusion 2</a></li>
<li><a href="#exclusion-1" id="toc-exclusion-1" class="nav-link" data-scroll-target="#exclusion-1">Exclusion 1</a></li>
<li><a href="#treatment-of-late-responses-and-wrong-responses" id="toc-treatment-of-late-responses-and-wrong-responses" class="nav-link" data-scroll-target="#treatment-of-late-responses-and-wrong-responses">Treatment of late responses and wrong responses</a></li>
<li><a href="#exploring-late-responses" id="toc-exploring-late-responses" class="nav-link" data-scroll-target="#exploring-late-responses">Exploring Late Responses</a></li>
<li><a href="#half-violin" id="toc-half-violin" class="nav-link" data-scroll-target="#half-violin">Half violin</a></li>
<li><a href="#check-block-1-2-3---no-difference-in-speed-and-accuracy" id="toc-check-block-1-2-3---no-difference-in-speed-and-accuracy" class="nav-link" data-scroll-target="#check-block-1-2-3---no-difference-in-speed-and-accuracy">Check Block 1, 2, 3 - No Difference in Speed and Accuracy</a></li>
</ul></li>
<li><a href="#eye-tracking-data-cleaning" id="toc-eye-tracking-data-cleaning" class="nav-link" data-scroll-target="#eye-tracking-data-cleaning">Eye Tracking Data Cleaning</a>
<ul class="collapse">
<li><a href="#major-cleanup" id="toc-major-cleanup" class="nav-link" data-scroll-target="#major-cleanup">Major cleanup</a></li>
<li><a href="#adjust-for-video-positions" id="toc-adjust-for-video-positions" class="nav-link" data-scroll-target="#adjust-for-video-positions">Adjust for video positions</a></li>
<li><a href="#eyetrack_data-created-here" id="toc-eyetrack_data-created-here" class="nav-link" data-scroll-target="#eyetrack_data-created-here">EYETRACK_DATA created here</a></li>
<li><a href="#deprecated-exploring-1000-ms-and-500-ms-before-pour_moment" id="toc-deprecated-exploring-1000-ms-and-500-ms-before-pour_moment" class="nav-link" data-scroll-target="#deprecated-exploring-1000-ms-and-500-ms-before-pour_moment">DEPRECATED Exploring 1000 ms and 500 ms before pour_moment</a></li>
</ul></li>
<li><a href="#time-bins-of-50" id="toc-time-bins-of-50" class="nav-link" data-scroll-target="#time-bins-of-50">Time Bins of 50</a></li>
<li><a href="#time-window" id="toc-time-window" class="nav-link" data-scroll-target="#time-window">Time Window</a></li>
<li><a href="#aggregate-calculate-predictive-gaze" id="toc-aggregate-calculate-predictive-gaze" class="nav-link" data-scroll-target="#aggregate-calculate-predictive-gaze">Aggregate: Calculate predictive gaze</a>
<ul class="collapse">
<li><a href="#check-participants-who-failed-to-look-at-both-aois" id="toc-check-participants-who-failed-to-look-at-both-aois" class="nav-link" data-scroll-target="#check-participants-who-failed-to-look-at-both-aois">Check participants who failed to look at both AOIs</a></li>
<li><a href="#check-participants-who-fixated-only-on-the-goal-aoi" id="toc-check-participants-who-fixated-only-on-the-goal-aoi" class="nav-link" data-scroll-target="#check-participants-who-fixated-only-on-the-goal-aoi">Check participants who fixated only on the Goal AOI</a></li>
<li><a href="#mean-predictive-gaze-calculated-here" id="toc-mean-predictive-gaze-calculated-here" class="nav-link" data-scroll-target="#mean-predictive-gaze-calculated-here">Mean Predictive Gaze calculated here</a></li>
</ul></li>
<li><a href="#violin" id="toc-violin" class="nav-link" data-scroll-target="#violin">Violin</a></li>
<li><a href="#check-not-looking-and-infinity" id="toc-check-not-looking-and-infinity" class="nav-link" data-scroll-target="#check-not-looking-and-infinity">Check Not Looking and Infinity</a>
<ul class="collapse">
<li><a href="#equal-time-bins-of-20ms" id="toc-equal-time-bins-of-20ms" class="nav-link" data-scroll-target="#equal-time-bins-of-20ms">Equal Time Bins of 20ms</a></li>
<li><a href="#exploring-how-to-filter-the-noisy-data" id="toc-exploring-how-to-filter-the-noisy-data" class="nav-link" data-scroll-target="#exploring-how-to-filter-the-noisy-data">Exploring how to filter the noisy data</a></li>
</ul></li>
</ul>
</nav>
</div>
<main class="content" id="quarto-document-content">
<header id="title-block-header" class="quarto-title-block default">
<div class="quarto-title">
<h1 class="title">Data Cleaning, Wrangling, and Exploration</h1>
</div>
<div class="quarto-title-meta">
<div>
<div class="quarto-title-meta-heading">Published</div>
<div class="quarto-title-meta-contents">
<p class="date">April 25, 2023</p>
</div>
</div>
</div>
</header>
<section id="load-files" class="level2">
<h2 class="anchored" data-anchor-id="load-files">Load files</h2>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="#cb1-1" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(tidyverse) </span>
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(stringr) </span>
<span id="cb1-3"><a href="#cb1-3" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(geomtextpath) <span class="co"># for annotating geom_vlines</span></span>
<span id="cb1-4"><a href="#cb1-4" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(mosaic, <span class="at">include.only =</span> <span class="st">'favstats'</span>)</span>
<span id="cb1-5"><a href="#cb1-5" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(knitr, <span class="at">include.only=</span><span class="st">'kable'</span>)</span>
<span id="cb1-6"><a href="#cb1-6" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(eyetrackingR) <span class="co"># add_aoi, need equal time windows</span></span>
<span id="cb1-7"><a href="#cb1-7" aria-hidden="true" tabindex="-1"></a><span class="fu">library</span>(wesanderson)</span>
<span id="cb1-8"><a href="#cb1-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-9"><a href="#cb1-9" aria-hidden="true" tabindex="-1"></a>list_of_files_with_ID <span class="ot"><-</span> <span class="fu">list.files</span>(<span class="at">path =</span> <span class="st">"data_5/"</span>,</span>
<span id="cb1-10"><a href="#cb1-10" aria-hidden="true" tabindex="-1"></a> <span class="at">recursive =</span> <span class="cn">TRUE</span>,</span>
<span id="cb1-11"><a href="#cb1-11" aria-hidden="true" tabindex="-1"></a> <span class="at">pattern =</span> <span class="st">"</span><span class="sc">\\</span><span class="st">.csv$"</span>,</span>
<span id="cb1-12"><a href="#cb1-12" aria-hidden="true" tabindex="-1"></a> <span class="at">full.names =</span> <span class="cn">TRUE</span>)</span>
<span id="cb1-13"><a href="#cb1-13" aria-hidden="true" tabindex="-1"></a><span class="co"># writeLines(list_of_files, "filenames.txt")</span></span>
<span id="cb1-14"><a href="#cb1-14" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb1-15"><a href="#cb1-15" aria-hidden="true" tabindex="-1"></a>df <span class="ot"><-</span> list_of_files_with_ID <span class="sc">%>%</span> <span class="fu">setNames</span>(<span class="at">nm =</span> .) <span class="sc">%>%</span></span>
<span id="cb1-16"><a href="#cb1-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">map_df</span>(<span class="sc">~</span><span class="fu">read_csv</span>(<span class="at">file =</span> .x, <span class="at">col_types =</span> <span class="fu">cols</span>()), <span class="at">.id =</span> <span class="st">"participant"</span>) <span class="sc">%>%</span></span>
<span id="cb1-17"><a href="#cb1-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">participant =</span> <span class="fu">str_extract</span>(participant, <span class="st">"V</span><span class="sc">\\</span><span class="st">d{3}"</span>)</span>
<span id="cb1-18"><a href="#cb1-18" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb1-19"><a href="#cb1-19" aria-hidden="true" tabindex="-1"></a><span class="co"># above did not work with baseR pipe |>, had to use the tidy pipe</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
</section>
<section id="examine-validation-scores" class="level2">
<h2 class="anchored" data-anchor-id="examine-validation-scores">Examine validation scores</h2>
<p>Validation scores are calculated percent_in_roi column.</p>
<p>The preregistered exclusion method is 55% validation accuracy within 2 rounds (gaze falls within 200px radius of 5 validation points).</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a><span class="co"># column percent_in_roi has brackets [], function to remove</span></span>
<span id="cb2-2"><a href="#cb2-2" aria-hidden="true" tabindex="-1"></a>remove_brackets <span class="ot"><-</span> <span class="cf">function</span>(col) {</span>
<span id="cb2-3"><a href="#cb2-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">[|</span><span class="sc">\\</span><span class="st">]"</span>, <span class="st">""</span>, col)</span>
<span id="cb2-4"><a href="#cb2-4" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb2-5"><a href="#cb2-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-6"><a href="#cb2-6" aria-hidden="true" tabindex="-1"></a><span class="co"># percent_in_roi originally is a string, e.g., "[100, 100, 100, 100, 100]"</span></span>
<span id="cb2-7"><a href="#cb2-7" aria-hidden="true" tabindex="-1"></a><span class="co"># remove brackets, str_split into list of 5 strings, e.g., c("100", "100", "100", "100", "100")</span></span>
<span id="cb2-8"><a href="#cb2-8" aria-hidden="true" tabindex="-1"></a>df_percent_in_roi <span class="ot"><-</span> df <span class="sc">|></span> <span class="fu">group_by</span>(participant) <span class="sc">|></span> </span>
<span id="cb2-9"><a href="#cb2-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(participant, percent_in_roi) <span class="sc">|></span> <span class="fu">drop_na</span>() <span class="sc">|></span> </span>
<span id="cb2-10"><a href="#cb2-10" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">percent_in_roi =</span> <span class="fu">remove_brackets</span>(percent_in_roi)) <span class="sc">|></span> </span>
<span id="cb2-11"><a href="#cb2-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">list_percent =</span> <span class="fu">str_split</span>(percent_in_roi, <span class="st">","</span>))</span>
<span id="cb2-12"><a href="#cb2-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-13"><a href="#cb2-13" aria-hidden="true" tabindex="-1"></a><span class="co"># split the list of string into 5 columns, for each column, as.numeric()</span></span>
<span id="cb2-14"><a href="#cb2-14" aria-hidden="true" tabindex="-1"></a>df_calculate_mean <span class="ot"><-</span> df_percent_in_roi <span class="sc">|></span> <span class="fu">select</span>(participant, list_percent) <span class="sc">|></span> <span class="fu">unnest_wider</span>(list_percent, <span class="at">names_sep =</span> <span class="st">"."</span>) <span class="sc">|></span></span>
<span id="cb2-15"><a href="#cb2-15" aria-hidden="true" tabindex="-1"></a><span class="fu">mutate_at</span>(<span class="fu">c</span>(<span class="st">'list_percent.1'</span>, <span class="st">'list_percent.2'</span>, <span class="st">'list_percent.3'</span>, <span class="st">'list_percent.4'</span>, <span class="st">'list_percent.5'</span>), as.numeric) <span class="sc">|></span> </span>
<span id="cb2-16"><a href="#cb2-16" aria-hidden="true" tabindex="-1"></a> <span class="co"># calculate means for each row, i.e., each round of validation</span></span>
<span id="cb2-17"><a href="#cb2-17" aria-hidden="true" tabindex="-1"></a> <span class="co"># create boolean column to indicate whether participants passed 55% threshold or not</span></span>
<span id="cb2-18"><a href="#cb2-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(</span>
<span id="cb2-19"><a href="#cb2-19" aria-hidden="true" tabindex="-1"></a> <span class="at">mean_col =</span> <span class="fu">rowMeans</span>(<span class="fu">cbind</span>(list_percent<span class="fl">.1</span>, list_percent<span class="fl">.2</span>, </span>
<span id="cb2-20"><a href="#cb2-20" aria-hidden="true" tabindex="-1"></a> list_percent<span class="fl">.3</span>, list_percent<span class="fl">.4</span>, </span>
<span id="cb2-21"><a href="#cb2-21" aria-hidden="true" tabindex="-1"></a> list_percent<span class="fl">.5</span>), <span class="at">na.rm=</span>F)) <span class="sc">|></span> </span>
<span id="cb2-22"><a href="#cb2-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">boolean =</span> <span class="fu">case_when</span>(mean_col <span class="sc">>=</span> <span class="fl">55.0</span> <span class="sc">~</span> <span class="cn">TRUE</span>, </span>
<span id="cb2-23"><a href="#cb2-23" aria-hidden="true" tabindex="-1"></a> mean_col <span class="sc"><</span> <span class="dv">55</span> <span class="sc">~</span> <span class="cn">FALSE</span>))</span>
<span id="cb2-24"><a href="#cb2-24" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb2-25"><a href="#cb2-25" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(df_calculate_mean, <span class="at">n=</span><span class="dv">10</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["list_percent.1"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["list_percent.2"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["list_percent.3"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["list_percent.4"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["list_percent.5"],"name":[6],"type":["dbl"],"align":["right"]},{"label":["mean_col"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["boolean"],"name":[8],"type":["lgl"],"align":["right"]}],"data":[{"1":"V001","2":"63.513514","3":"93.24324","4":"63.51351","5":"98.630137","6":"17.808219","7":"67.34173","8":"TRUE"},{"1":"V002","2":"89.189189","3":"60.56338","4":"85.91549","5":"88.888889","6":"100.000000","7":"84.91139","8":"TRUE"},{"1":"V003","2":"100.000000","3":"81.08108","4":"87.83784","5":"81.333333","6":"0.000000","7":"70.05045","8":"TRUE"},{"1":"V004","2":"100.000000","3":"98.00000","4":"84.90566","5":"16.981132","6":"1.923077","7":"60.36197","8":"TRUE"},{"1":"V005","2":"100.000000","3":"55.35714","4":"100.00000","5":"32.758621","6":"100.000000","7":"77.62315","8":"TRUE"},{"1":"V006","2":"2.739726","3":"0.00000","4":"100.00000","5":"56.756757","6":"84.000000","7":"48.69930","8":"FALSE"},{"1":"V006","2":"100.000000","3":"63.51351","4":"100.00000","5":"100.000000","6":"87.837838","7":"90.27027","8":"TRUE"},{"1":"V007","2":"87.837838","3":"100.00000","4":"100.00000","5":"86.301370","6":"95.890411","7":"94.00592","8":"TRUE"},{"1":"V008","2":"100.000000","3":"80.55556","4":"84.50704","5":"1.351351","6":"72.463768","7":"67.77554","8":"TRUE"},{"1":"V009","2":"78.571429","3":"27.11864","4":"72.72727","5":"78.947368","6":"7.017544","7":"52.87645","8":"FALSE"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
<section id="get-higher-validation-score-for-participants-if-2-rounds-of-validation" class="level3">
<h3 class="anchored" data-anchor-id="get-higher-validation-score-for-participants-if-2-rounds-of-validation">Get higher validation score for participants, if 2 rounds of validation</h3>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a><span class="co"># generate participant list who reach 55% within 2 rounds of validation</span></span>
<span id="cb3-2"><a href="#cb3-2" aria-hidden="true" tabindex="-1"></a><span class="co"># retain rows with higher validation percent in mean_col, using top_n()</span></span>
<span id="cb3-3"><a href="#cb3-3" aria-hidden="true" tabindex="-1"></a>participant_list_eye_tracking <span class="ot"><-</span> df_calculate_mean <span class="sc">|></span> </span>
<span id="cb3-4"><a href="#cb3-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(participant) <span class="sc">|></span> <span class="fu">top_n</span>(<span class="dv">1</span>, mean_col)</span>
<span id="cb3-5"><a href="#cb3-5" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb3-6"><a href="#cb3-6" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(participant_list_eye_tracking))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["list_percent.1"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["list_percent.2"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["list_percent.3"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["list_percent.4"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["list_percent.5"],"name":[6],"type":["dbl"],"align":["right"]},{"label":["mean_col"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["boolean"],"name":[8],"type":["lgl"],"align":["right"]}],"data":[{"1":"V001","2":"63.51351","3":"93.24324","4":"63.51351","5":"98.63014","6":"17.808219","7":"67.34173","8":"TRUE"},{"1":"V002","2":"89.18919","3":"60.56338","4":"85.91549","5":"88.88889","6":"100.000000","7":"84.91139","8":"TRUE"},{"1":"V003","2":"100.00000","3":"81.08108","4":"87.83784","5":"81.33333","6":"0.000000","7":"70.05045","8":"TRUE"},{"1":"V004","2":"100.00000","3":"98.00000","4":"84.90566","5":"16.98113","6":"1.923077","7":"60.36197","8":"TRUE"},{"1":"V005","2":"100.00000","3":"55.35714","4":"100.00000","5":"32.75862","6":"100.000000","7":"77.62315","8":"TRUE"},{"1":"V006","2":"100.00000","3":"63.51351","4":"100.00000","5":"100.00000","6":"87.837838","7":"90.27027","8":"TRUE"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
</section>
<section id="quick-calculation-what-if-we-were-to-use-validation-score-above-80-on-any-of-5-points" class="level3">
<h3 class="anchored" data-anchor-id="quick-calculation-what-if-we-were-to-use-validation-score-above-80-on-any-of-5-points">Quick calculation: what if we were to use “validation score above 80% on any of 5 points”</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb4"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>q <span class="ot"><-</span> participant_list_eye_tracking <span class="sc">|></span> </span>
<span id="cb4-2"><a href="#cb4-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">max_percent_of_single_point =</span> <span class="fu">max</span>(<span class="fu">c</span>(list_percent<span class="fl">.1</span>, list_percent<span class="fl">.2</span>, list_percent<span class="fl">.3</span>, list_percent<span class="fl">.4</span>, list_percent<span class="fl">.5</span>))) <span class="sc">|></span> </span>
<span id="cb4-3"><a href="#cb4-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">above_80 =</span> <span class="fu">case_when</span>(</span>
<span id="cb4-4"><a href="#cb4-4" aria-hidden="true" tabindex="-1"></a> max_percent_of_single_point <span class="sc">>=</span> <span class="dv">80</span> <span class="sc">~</span><span class="cn">TRUE</span>, </span>
<span id="cb4-5"><a href="#cb4-5" aria-hidden="true" tabindex="-1"></a> max_percent_of_single_point <span class="sc"><</span> <span class="dv">80</span> <span class="sc">~</span> <span class="cn">FALSE</span></span>
<span id="cb4-6"><a href="#cb4-6" aria-hidden="true" tabindex="-1"></a> ))</span>
<span id="cb4-7"><a href="#cb4-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb4-8"><a href="#cb4-8" aria-hidden="true" tabindex="-1"></a>q <span class="sc">|></span> <span class="fu">group_by</span>(above_80) <span class="sc">|></span> <span class="fu">count</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code># A tibble: 2 × 2
# Groups: above_80 [2]
above_80 n
<lgl> <int>
1 FALSE 8
2 TRUE 54</code></pre>
</div>
</div>
<p>FALSE 8<br>
TRUE 54<br>
Conclusion: If we use the approach of 80% score on any validation point, then we would only exclude 8 participants.</p>
</section>
<section id="subset-for-participants-who-passed-the-threshold" class="level3">
<h3 class="anchored" data-anchor-id="subset-for-participants-who-passed-the-threshold">Subset for participants who passed the threshold</h3>
<p><code>narrow_participant_list_eye_tracking</code> is the list of participants whose data we will use for eye-tracking analysis.</p>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb6"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a><span class="co"># subset data of participants who passed the validation score threshold</span></span>
<span id="cb6-2"><a href="#cb6-2" aria-hidden="true" tabindex="-1"></a>narrow_participant_list_eye_tracking <span class="ot"><-</span> participant_list_eye_tracking <span class="sc">|></span> <span class="fu">filter</span>(boolean <span class="sc">==</span> <span class="cn">TRUE</span>)</span>
<span id="cb6-3"><a href="#cb6-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb6-4"><a href="#cb6-4" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(narrow_participant_list_eye_tracking))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["list_percent.1"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["list_percent.2"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["list_percent.3"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["list_percent.4"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["list_percent.5"],"name":[6],"type":["dbl"],"align":["right"]},{"label":["mean_col"],"name":[7],"type":["dbl"],"align":["right"]},{"label":["boolean"],"name":[8],"type":["lgl"],"align":["right"]}],"data":[{"1":"V001","2":"63.51351","3":"93.24324","4":"63.51351","5":"98.63014","6":"17.808219","7":"67.34173","8":"TRUE"},{"1":"V002","2":"89.18919","3":"60.56338","4":"85.91549","5":"88.88889","6":"100.000000","7":"84.91139","8":"TRUE"},{"1":"V003","2":"100.00000","3":"81.08108","4":"87.83784","5":"81.33333","6":"0.000000","7":"70.05045","8":"TRUE"},{"1":"V004","2":"100.00000","3":"98.00000","4":"84.90566","5":"16.98113","6":"1.923077","7":"60.36197","8":"TRUE"},{"1":"V005","2":"100.00000","3":"55.35714","4":"100.00000","5":"32.75862","6":"100.000000","7":"77.62315","8":"TRUE"},{"1":"V006","2":"100.00000","3":"63.51351","4":"100.00000","5":"100.00000","6":"87.837838","7":"90.27027","8":"TRUE"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
</section>
<section id="descriptive-statistics-of-all-participants" class="level3">
<h3 class="anchored" data-anchor-id="descriptive-statistics-of-all-participants">Descriptive statistics of all participants</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb7"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a><span class="co"># descriptive stats on mean_col of ALL participants</span></span>
<span id="cb7-2"><a href="#cb7-2" aria-hidden="true" tabindex="-1"></a>descriptive_stats_mean_validation_scores <span class="ot"><-</span> <span class="fu">favstats</span>(<span class="sc">~</span>mean_col, <span class="at">data =</span> participant_list_eye_tracking)</span>
<span id="cb7-3"><a href="#cb7-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb7-4"><a href="#cb7-4" aria-hidden="true" tabindex="-1"></a>knitr<span class="sc">::</span><span class="fu">kable</span>(descriptive_stats_mean_validation_scores, <span class="at">align =</span> <span class="st">"c"</span>, </span>
<span id="cb7-5"><a href="#cb7-5" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">"Descriptive statistics, validation scores of all participants"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<caption>Descriptive statistics, validation scores of all participants</caption>
<colgroup>
<col style="width: 3%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 4%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: left;"></th>
<th style="text-align: center;">min</th>
<th style="text-align: center;">Q1</th>
<th style="text-align: center;">median</th>
<th style="text-align: center;">Q3</th>
<th style="text-align: center;">max</th>
<th style="text-align: center;">mean</th>
<th style="text-align: center;">sd</th>
<th style="text-align: center;">n</th>
<th style="text-align: center;">missing</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: left;"></td>
<td style="text-align: center;">7.567568</td>
<td style="text-align: center;">45.59098</td>
<td style="text-align: center;">59.43423</td>
<td style="text-align: center;">70.03414</td>
<td style="text-align: center;">94.59459</td>
<td style="text-align: center;">57.93148</td>
<td style="text-align: center;">18.57287</td>
<td style="text-align: center;">62</td>
<td style="text-align: center;">0</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
<section id="histogram-and-density-curve-of-all-participants" class="level3">
<h3 class="anchored" data-anchor-id="histogram-and-density-curve-of-all-participants">Histogram and density curve of all participants</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb8"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(participant_list_eye_tracking, <span class="fu">aes</span>(<span class="at">x=</span>mean_col)) <span class="sc">+</span> </span>
<span id="cb8-2"><a href="#cb8-2" aria-hidden="true" tabindex="-1"></a> <span class="co">#set histogram and density plot</span></span>
<span id="cb8-3"><a href="#cb8-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_histogram</span>(<span class="fu">aes</span>(<span class="at">y =</span> <span class="fu">after_stat</span>(density)), <span class="at">binwidth =</span> <span class="dv">2</span>) <span class="sc">+</span> </span>
<span id="cb8-4"><a href="#cb8-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_density</span>(<span class="at">color=</span><span class="st">"blue"</span>, <span class="at">linewidth =</span> <span class="dv">1</span>) <span class="sc">+</span></span>
<span id="cb8-5"><a href="#cb8-5" aria-hidden="true" tabindex="-1"></a> <span class="co">#set theme</span></span>
<span id="cb8-6"><a href="#cb8-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb8-7"><a href="#cb8-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(</span>
<span id="cb8-8"><a href="#cb8-8" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.margin =</span> <span class="fu">margin</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>, <span class="st">"cm"</span>), </span>
<span id="cb8-9"><a href="#cb8-9" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.title =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">18</span>), </span>
<span id="cb8-10"><a href="#cb8-10" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.subtitle =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">14</span>), </span>
<span id="cb8-11"><a href="#cb8-11" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">14</span>)</span>
<span id="cb8-12"><a href="#cb8-12" aria-hidden="true" tabindex="-1"></a> ) <span class="sc">+</span></span>
<span id="cb8-13"><a href="#cb8-13" aria-hidden="true" tabindex="-1"></a> <span class="co"># add vlines to indicate mean, SD from mean, and where the 55% threshold is</span></span>
<span id="cb8-14"><a href="#cb8-14" aria-hidden="true" tabindex="-1"></a> <span class="co"># using geomtextpath::geom_textvline which combines vline and annotation settings</span></span>
<span id="cb8-15"><a href="#cb8-15" aria-hidden="true" tabindex="-1"></a> <span class="co"># mean</span></span>
<span id="cb8-16"><a href="#cb8-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_textvline</span>(<span class="at">label =</span> <span class="st">"mean"</span>, <span class="at">xintercept =</span> <span class="fu">mean</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col), </span>
<span id="cb8-17"><a href="#cb8-17" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"blue"</span>, <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>, <span class="at">hjust =</span> .<span class="dv">9</span>, <span class="at">fontface =</span> <span class="st">"bold"</span>) <span class="sc">+</span></span>
<span id="cb8-18"><a href="#cb8-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_textvline</span>(<span class="at">label =</span> <span class="st">"3SD from mean"</span>, <span class="at">xintercept =</span> (<span class="fu">mean</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col) <span class="sc">-</span> <span class="fu">sd</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col)<span class="sc">*</span><span class="dv">3</span>), </span>
<span id="cb8-19"><a href="#cb8-19" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"orange"</span>, <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>, <span class="at">hjust =</span> .<span class="dv">9</span>, <span class="at">fontface =</span> <span class="st">"bold"</span>) <span class="sc">+</span></span>
<span id="cb8-20"><a href="#cb8-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_textvline</span>(<span class="at">label =</span> <span class="st">"2SD from mean"</span>, <span class="at">xintercept=</span>(<span class="fu">mean</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col) <span class="sc">-</span> <span class="fu">sd</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col)<span class="sc">*</span><span class="dv">2</span>), </span>
<span id="cb8-21"><a href="#cb8-21" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"orange"</span>, <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>, <span class="at">hjust =</span> .<span class="dv">9</span>, <span class="at">fontface =</span> <span class="st">"bold"</span>) <span class="sc">+</span></span>
<span id="cb8-22"><a href="#cb8-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_textvline</span>(<span class="at">label =</span> <span class="st">"1 SD from mean"</span>, <span class="at">xintercept=</span>(<span class="fu">mean</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col) <span class="sc">-</span> <span class="fu">sd</span>(participant_list_eye_tracking<span class="sc">$</span>mean_col)), </span>
<span id="cb8-23"><a href="#cb8-23" aria-hidden="true" tabindex="-1"></a> <span class="at">color =</span> <span class="st">"orange"</span>, <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>, <span class="at">linetype=</span><span class="st">"dashed"</span>, <span class="at">hjust =</span> .<span class="dv">9</span>, <span class="at">fontface =</span> <span class="st">"bold"</span>) <span class="sc">+</span> </span>
<span id="cb8-24"><a href="#cb8-24" aria-hidden="true" tabindex="-1"></a> <span class="co">#55% threshold</span></span>
<span id="cb8-25"><a href="#cb8-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_textvline</span>(<span class="at">label =</span> <span class="st">"55% threshold"</span>, <span class="at">xintercept =</span> <span class="dv">53</span>, <span class="at">color =</span> <span class="st">"cyan"</span>, <span class="at">vjust =</span> <span class="sc">-</span>.<span class="dv">5</span>, <span class="at">hjust =</span> .<span class="dv">9</span>, <span class="at">fontface =</span> <span class="st">"bold"</span>) <span class="sc">+</span></span>
<span id="cb8-26"><a href="#cb8-26" aria-hidden="true" tabindex="-1"></a><span class="co"># set plot titles</span></span>
<span id="cb8-27"><a href="#cb8-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Distribution of validation scores"</span>, <span class="at">subtitle =</span> <span class="st">"Higher score of 2 validation rounds, where applicable; binwidth = 2"</span>) <span class="sc">+</span> </span>
<span id="cb8-28"><a href="#cb8-28" aria-hidden="true" tabindex="-1"></a><span class="co"># set axis labels</span></span>
<span id="cb8-29"><a href="#cb8-29" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_continuous</span>(<span class="at">name =</span> <span class="st">"Validation score (%)"</span>, <span class="at">limits=</span><span class="fu">c</span>(<span class="sc">-</span><span class="dv">11</span>, <span class="dv">105</span>), <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">0</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<p><img src="Preprocessing_files/figure-html/unnamed-chunk-4-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="box-and-whisker-plot-validation-scores-of-all-participants" class="level3">
<h3 class="anchored" data-anchor-id="box-and-whisker-plot-validation-scores-of-all-participants">Box and whisker plot, validation scores of all participants</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb9"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(participant_list_eye_tracking, <span class="fu">aes</span>(<span class="at">x =</span> mean_col))<span class="sc">+</span></span>
<span id="cb9-2"><a href="#cb9-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_boxplot</span>() <span class="sc">+</span></span>
<span id="cb9-3"><a href="#cb9-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_continuous</span>(<span class="at">name =</span> <span class="st">"Validation score (%)"</span>, </span>
<span id="cb9-4"><a href="#cb9-4" aria-hidden="true" tabindex="-1"></a> <span class="at">limits=</span><span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">100</span>), </span>
<span id="cb9-5"><a href="#cb9-5" aria-hidden="true" tabindex="-1"></a> <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">0</span>)) <span class="sc">+</span> </span>
<span id="cb9-6"><a href="#cb9-6" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_bw</span>(<span class="at">base_size=</span><span class="dv">16</span>) <span class="sc">+</span></span>
<span id="cb9-7"><a href="#cb9-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">axis.text.y =</span> <span class="fu">element_blank</span>(), </span>
<span id="cb9-8"><a href="#cb9-8" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.ticks.y =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb9-9"><a href="#cb9-9" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.margin =</span> <span class="fu">margin</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>, <span class="st">"cm"</span>), </span>
<span id="cb9-10"><a href="#cb9-10" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.title =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">18</span>), </span>
<span id="cb9-11"><a href="#cb9-11" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.subtitle =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">14</span>), </span>
<span id="cb9-12"><a href="#cb9-12" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">14</span>)) <span class="sc">+</span> </span>
<span id="cb9-13"><a href="#cb9-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"Distribution of validation scores"</span>, <span class="at">subtitle =</span> <span class="st">"Higher score of 2 rounds where applicable"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<p><img src="Preprocessing_files/figure-html/unnamed-chunk-5-1.png" class="img-fluid" width="672"></p>
</div>
</div>
</section>
<section id="descriptive-statistics-for-each-validation-point" class="level3">
<h3 class="anchored" data-anchor-id="descriptive-statistics-for-each-validation-point">Descriptive statistics for each validation point</h3>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb10"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a><span class="co">#table for each validation point, mean, sd of validation scores</span></span>
<span id="cb10-2"><a href="#cb10-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-3"><a href="#cb10-3" aria-hidden="true" tabindex="-1"></a>m1 <span class="ot"><-</span> <span class="fu">favstats</span>(narrow_participant_list_eye_tracking<span class="sc">$</span>list_percent<span class="fl">.1</span>) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">point =</span><span class="st">"[25, 25]"</span>, <span class="at">.before =</span> min)</span>
<span id="cb10-4"><a href="#cb10-4" aria-hidden="true" tabindex="-1"></a>m2 <span class="ot"><-</span> <span class="fu">favstats</span>(narrow_participant_list_eye_tracking<span class="sc">$</span>list_percent<span class="fl">.2</span>) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">point =</span><span class="st">"[75, 25]"</span>, <span class="at">.before =</span> min)</span>
<span id="cb10-5"><a href="#cb10-5" aria-hidden="true" tabindex="-1"></a>m3 <span class="ot"><-</span> <span class="fu">favstats</span>(narrow_participant_list_eye_tracking<span class="sc">$</span>list_percent<span class="fl">.3</span>) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">point =</span><span class="st">"[50, 50]"</span>, <span class="at">.before =</span> min)</span>
<span id="cb10-6"><a href="#cb10-6" aria-hidden="true" tabindex="-1"></a>m4 <span class="ot"><-</span> <span class="fu">favstats</span>(narrow_participant_list_eye_tracking<span class="sc">$</span>list_percent<span class="fl">.4</span>) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">point =</span><span class="st">"[25,75]"</span>, <span class="at">.before =</span> min)</span>
<span id="cb10-7"><a href="#cb10-7" aria-hidden="true" tabindex="-1"></a>m5 <span class="ot"><-</span> <span class="fu">favstats</span>(narrow_participant_list_eye_tracking<span class="sc">$</span>list_percent<span class="fl">.5</span>) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">point =</span><span class="st">"[75, 75]"</span>, <span class="at">.before =</span> min)</span>
<span id="cb10-8"><a href="#cb10-8" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-9"><a href="#cb10-9" aria-hidden="true" tabindex="-1"></a><span class="co">#descriptive stats for each validation point</span></span>
<span id="cb10-10"><a href="#cb10-10" aria-hidden="true" tabindex="-1"></a>each_validation_point <span class="ot"><-</span> <span class="fu">rbind</span>(m1, m2, m3, m4, m5) </span>
<span id="cb10-11"><a href="#cb10-11" aria-hidden="true" tabindex="-1"></a><span class="fu">rownames</span>(each_validation_point) <span class="ot"><-</span> <span class="cn">NULL</span> <span class="co">#turn off automatically assigned row names</span></span>
<span id="cb10-12"><a href="#cb10-12" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb10-13"><a href="#cb10-13" aria-hidden="true" tabindex="-1"></a>knitr<span class="sc">::</span><span class="fu">kable</span>(each_validation_point, <span class="at">align=</span><span class="st">"c"</span>, </span>
<span id="cb10-14"><a href="#cb10-14" aria-hidden="true" tabindex="-1"></a> <span class="at">caption =</span> <span class="st">"**Participants who passed the 55% threshold, validation scores on each data point**"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<table class="table table-sm table-striped">
<caption><strong>Participants who passed the 55% threshold, validation scores on each data point</strong></caption>
<colgroup>
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 12%">
<col style="width: 5%">
<col style="width: 11%">
<col style="width: 11%">
<col style="width: 4%">
<col style="width: 10%">
</colgroup>
<thead>
<tr class="header">
<th style="text-align: center;">point</th>
<th style="text-align: center;">min</th>
<th style="text-align: center;">Q1</th>
<th style="text-align: center;">median</th>
<th style="text-align: center;">Q3</th>
<th style="text-align: center;">max</th>
<th style="text-align: center;">mean</th>
<th style="text-align: center;">sd</th>
<th style="text-align: center;">n</th>
<th style="text-align: center;">missing</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td style="text-align: center;">[25, 25]</td>
<td style="text-align: center;">0.00000</td>
<td style="text-align: center;">85.78579</td>
<td style="text-align: center;">96.21859</td>
<td style="text-align: center;">100.00000</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">85.91404</td>
<td style="text-align: center;">23.22511</td>
<td style="text-align: center;">36</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="even">
<td style="text-align: center;">[75, 25]</td>
<td style="text-align: center;">0.00000</td>
<td style="text-align: center;">56.69643</td>
<td style="text-align: center;">80.81832</td>
<td style="text-align: center;">97.44521</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">69.97007</td>
<td style="text-align: center;">31.27701</td>
<td style="text-align: center;">36</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="odd">
<td style="text-align: center;">[50, 50]</td>
<td style="text-align: center;">35.13514</td>
<td style="text-align: center;">82.00140</td>
<td style="text-align: center;">92.43717</td>
<td style="text-align: center;">100.00000</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">86.81598</td>
<td style="text-align: center;">16.32402</td>
<td style="text-align: center;">36</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="even">
<td style="text-align: center;">[25,75]</td>
<td style="text-align: center;">0.00000</td>
<td style="text-align: center;">15.54054</td>
<td style="text-align: center;">73.76931</td>
<td style="text-align: center;">90.29680</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">55.71681</td>
<td style="text-align: center;">39.47861</td>
<td style="text-align: center;">36</td>
<td style="text-align: center;">0</td>
</tr>
<tr class="odd">
<td style="text-align: center;">[75, 75]</td>
<td style="text-align: center;">0.00000</td>
<td style="text-align: center;">12.58600</td>
<td style="text-align: center;">65.68034</td>
<td style="text-align: center;">88.51351</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">55.20860</td>
<td style="text-align: center;">38.92314</td>
<td style="text-align: center;">36</td>
<td style="text-align: center;">0</td>
</tr>
</tbody>
</table>
</div>
</div>
</section>
</section>
<section id="reaction-time-data" class="level2">
<h2 class="anchored" data-anchor-id="reaction-time-data">Reaction time data</h2>
<section id="cleanup" class="level3">
<h3 class="anchored" data-anchor-id="cleanup">Cleanup</h3>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb11"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href="#cb11-1" aria-hidden="true" tabindex="-1"></a>remove_brackets <span class="ot"><-</span> <span class="cf">function</span>(col) {</span>
<span id="cb11-2"><a href="#cb11-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">[|</span><span class="sc">\\</span><span class="st">]"</span>, <span class="st">""</span>, col)</span>
<span id="cb11-3"><a href="#cb11-3" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb11-4"><a href="#cb11-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-5"><a href="#cb11-5" aria-hidden="true" tabindex="-1"></a><span class="co"># load data on the frame just before liquid appears, in milliseconds</span></span>
<span id="cb11-6"><a href="#cb11-6" aria-hidden="true" tabindex="-1"></a>frame_before_outcome <span class="ot"><-</span> <span class="fu">read_csv</span>(<span class="st">"ReactionTime_FrameBeforeOutcome.csv"</span>)</span>
<span id="cb11-7"><a href="#cb11-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-8"><a href="#cb11-8" aria-hidden="true" tabindex="-1"></a>df_reaction_time <span class="ot"><-</span> df <span class="sc">|></span> <span class="fu">select</span>(participant, trial_index, rt, stimulus, response) <span class="sc">|></span> <span class="fu">drop_na</span>()</span>
<span id="cb11-9"><a href="#cb11-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-10"><a href="#cb11-10" aria-hidden="true" tabindex="-1"></a>reactionTime <span class="ot"><-</span> df_reaction_time <span class="sc">|></span></span>
<span id="cb11-11"><a href="#cb11-11" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(trial_index <span class="sc">></span> <span class="dv">14</span>) <span class="sc">|></span> <span class="co"># remove NA due to on-screen instructions appeared before trial_index 14 (response not captured)</span></span>
<span id="cb11-12"><a href="#cb11-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(trial_index <span class="sc">!=</span> <span class="dv">16</span>) <span class="sc">|></span> </span>
<span id="cb11-13"><a href="#cb11-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(stimulus <span class="sc">!=</span> <span class="st">"img/plus_thin.png"</span>) <span class="sc">|></span> <span class="co"># remove NA during fixation cross</span></span>
<span id="cb11-14"><a href="#cb11-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">grepl</span>(<span class="st">'>'</span>, stimulus)) <span class="sc">|></span> </span>
<span id="cb11-15"><a href="#cb11-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">remove_brackets</span>(stimulus)) <span class="sc">|></span> <span class="co"># remove brackets</span></span>
<span id="cb11-16"><a href="#cb11-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">gsub</span>(<span class="st">"</span><span class="sc">\\</span><span class="st">..*"</span>, <span class="st">""</span>, stimulus)) <span class="sc">|></span> <span class="co">#remove file extension .mp4</span></span>
<span id="cb11-17"><a href="#cb11-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">gsub</span>(<span class="st">".*/"</span>,<span class="st">""</span>, stimulus)) <span class="sc">|></span> <span class="co">#remove filepath videos/</span></span>
<span id="cb11-18"><a href="#cb11-18" aria-hidden="true" tabindex="-1"></a> <span class="co">#rename the human stimuli as file names too terse</span></span>
<span id="cb11-19"><a href="#cb11-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">str_replace_all</span>(stimulus, <span class="at">pattern =</span> <span class="st">"HBC"</span>, <span class="at">replacement =</span> <span class="st">"HumanBioCorrect"</span>)) <span class="sc">|></span> </span>
<span id="cb11-20"><a href="#cb11-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">str_replace_all</span>(stimulus, <span class="at">pattern =</span> <span class="st">"HBS"</span>, <span class="at">replacement =</span> <span class="st">"HumanBioSpill"</span>)) <span class="sc">|></span> </span>
<span id="cb11-21"><a href="#cb11-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">str_replace_all</span>(stimulus, <span class="at">pattern =</span> <span class="st">"HNBC"</span>, <span class="at">replacement =</span> <span class="st">"HumanNonbioCorrect"</span>)) <span class="sc">|></span> </span>
<span id="cb11-22"><a href="#cb11-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">str_replace_all</span>(stimulus, <span class="at">pattern =</span> <span class="st">"HNBS"</span>, <span class="at">replacement =</span> <span class="st">"HumanNonbioSpill"</span>)) <span class="sc">|></span></span>
<span id="cb11-23"><a href="#cb11-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(participant) <span class="sc">|></span> </span>
<span id="cb11-24"><a href="#cb11-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">trial_index =</span> <span class="fu">dense_rank</span>(<span class="fu">desc</span>(trial_index))) <span class="sc">|></span> <span class="fu">ungroup</span>() <span class="sc">|></span> </span>
<span id="cb11-25"><a href="#cb11-25" aria-hidden="true" tabindex="-1"></a><span class="co"># add column to indicate if the condition was "Correct" (f) or "Error" (j)</span></span>
<span id="cb11-26"><a href="#cb11-26" aria-hidden="true" tabindex="-1"></a><span class="co"># the stimulus names (video file names) contains the string "Spill" or "Correct"</span></span>
<span id="cb11-27"><a href="#cb11-27" aria-hidden="true" tabindex="-1"></a><span class="fu">mutate</span>(<span class="at">correct_answer =</span> <span class="fu">case_when</span>(</span>
<span id="cb11-28"><a href="#cb11-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Spill"</span>) <span class="sc">~</span> <span class="st">"j"</span>, <span class="fu">str_detect</span>(stimulus, <span class="st">"Correct"</span>) <span class="sc">~</span> <span class="st">"f"</span>)) <span class="sc">|></span></span>
<span id="cb11-29"><a href="#cb11-29" aria-hidden="true" tabindex="-1"></a><span class="co"># reaction time data were saved by jsPsych as string, we convert to numeric</span></span>
<span id="cb11-30"><a href="#cb11-30" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">rt =</span> <span class="fu">as.numeric</span>(rt)) <span class="sc">|></span> </span>
<span id="cb11-31"><a href="#cb11-31" aria-hidden="true" tabindex="-1"></a><span class="co"># join with csv frame_before_outcome loaded above </span></span>
<span id="cb11-32"><a href="#cb11-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">full_join</span>(frame_before_outcome) <span class="sc">|></span> </span>
<span id="cb11-33"><a href="#cb11-33" aria-hidden="true" tabindex="-1"></a><span class="co"># add column to calculate how much in advance participants gave key-press response</span></span>
<span id="cb11-34"><a href="#cb11-34" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">rt.adjusted =</span> (pour_moment <span class="sc">-</span> rt)) <span class="sc">|></span> </span>
<span id="cb11-35"><a href="#cb11-35" aria-hidden="true" tabindex="-1"></a> <span class="co"># add column of booleans comparing whether participants' answers were correct</span></span>
<span id="cb11-36"><a href="#cb11-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">accuracy =</span> <span class="fu">case_when</span>(</span>
<span id="cb11-37"><a href="#cb11-37" aria-hidden="true" tabindex="-1"></a> (response <span class="sc">==</span> correct_answer) <span class="sc">~</span> <span class="cn">TRUE</span>, </span>
<span id="cb11-38"><a href="#cb11-38" aria-hidden="true" tabindex="-1"></a> (response <span class="sc">!=</span> correct_answer) <span class="sc">~</span> <span class="cn">FALSE</span></span>
<span id="cb11-39"><a href="#cb11-39" aria-hidden="true" tabindex="-1"></a>), <span class="at">.before =</span> pour_moment)</span>
<span id="cb11-40"><a href="#cb11-40" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb11-41"><a href="#cb11-41" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(reactionTime, <span class="at">n =</span> <span class="dv">15</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["trial_index"],"name":[2],"type":["int"],"align":["right"]},{"label":["rt"],"name":[3],"type":["dbl"],"align":["right"]},{"label":["stimulus"],"name":[4],"type":["chr"],"align":["left"]},{"label":["response"],"name":[5],"type":["chr"],"align":["left"]},{"label":["correct_answer"],"name":[6],"type":["chr"],"align":["left"]},{"label":["accuracy"],"name":[7],"type":["lgl"],"align":["right"]},{"label":["pour_moment"],"name":[8],"type":["dbl"],"align":["right"]},{"label":["rt.adjusted"],"name":[9],"type":["dbl"],"align":["right"]}],"data":[{"1":"V001","2":"36","3":"4172","4":"TheoBioSpill","5":"f","6":"j","7":"FALSE","8":"5167","9":"995"},{"1":"V001","2":"35","3":"3996","4":"TheoNonbioCorrect","5":"f","6":"f","7":"TRUE","8":"5208","9":"1212"},{"1":"V001","2":"34","3":"4808","4":"TheoNonbioSpill","5":"f","6":"j","7":"FALSE","8":"5250","9":"442"},{"1":"V001","2":"33","3":"4642","4":"MiloNonbioSpill","5":"f","6":"j","7":"FALSE","8":"5167","9":"525"},{"1":"V001","2":"32","3":"5704","4":"HumanNonbioSpill","5":"f","6":"j","7":"FALSE","8":"5333","9":"-371"},{"1":"V001","2":"31","3":"5294","4":"MiloBioCorrect","5":"f","6":"f","7":"TRUE","8":"5208","9":"-86"},{"1":"V001","2":"30","3":"4973","4":"MiloNonbioCorrect","5":"f","6":"f","7":"TRUE","8":"5208","9":"235"},{"1":"V001","2":"29","3":"4918","4":"HumanBioCorrect","5":"f","6":"f","7":"TRUE","8":"5375","9":"457"},{"1":"V001","2":"28","3":"4178","4":"HumanBioSpill","5":"f","6":"j","7":"FALSE","8":"5208","9":"1030"},{"1":"V001","2":"27","3":"4300","4":"MiloBioSpill","5":"j","6":"j","7":"TRUE","8":"4958","9":"658"},{"1":"V001","2":"26","3":"3497","4":"HumanNonbioCorrect","5":"j","6":"f","7":"FALSE","8":"5333","9":"1836"},{"1":"V001","2":"25","3":"5199","4":"TheoBioCorrect","5":"f","6":"f","7":"TRUE","8":"5208","9":"9"},{"1":"V001","2":"24","3":"5758","4":"HumanBioCorrect","5":"f","6":"f","7":"TRUE","8":"5375","9":"-383"},{"1":"V001","2":"23","3":"5499","4":"MiloNonbioCorrect","5":"f","6":"f","7":"TRUE","8":"5208","9":"-291"},{"1":"V001","2":"22","3":"5556","4":"MiloNonbioSpill","5":"j","6":"j","7":"TRUE","8":"5167","9":"-389"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
<p><strong>Calculate accuracy rate for each participant</strong></p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="#cb12-1" aria-hidden="true" tabindex="-1"></a><span class="co"># group_by participant to work on exclusion 3</span></span>
<span id="cb12-2"><a href="#cb12-2" aria-hidden="true" tabindex="-1"></a>accuracy_for_each_participant <span class="ot"><-</span> reactionTime <span class="sc">|></span> <span class="fu">group_by</span>(participant, accuracy) <span class="sc">|></span> <span class="fu">count</span>() <span class="sc">|></span> </span>
<span id="cb12-3"><a href="#cb12-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">percent_accuracy =</span> n <span class="sc">/</span> <span class="dv">36</span> <span class="sc">*</span> <span class="dv">100</span>) <span class="sc">|></span> <span class="fu">filter</span>(accuracy <span class="sc">==</span> <span class="cn">TRUE</span>)</span>
<span id="cb12-4"><a href="#cb12-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb12-5"><a href="#cb12-5" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(accuracy_for_each_participant))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["accuracy"],"name":[2],"type":["lgl"],"align":["right"]},{"label":["n"],"name":[3],"type":["int"],"align":["right"]},{"label":["percent_accuracy"],"name":[4],"type":["dbl"],"align":["right"]}],"data":[{"1":"V001","2":"TRUE","3":"29","4":"80.55556"},{"1":"V002","2":"TRUE","3":"31","4":"86.11111"},{"1":"V003","2":"TRUE","3":"31","4":"86.11111"},{"1":"V004","2":"TRUE","3":"32","4":"88.88889"},{"1":"V005","2":"TRUE","3":"35","4":"97.22222"},{"1":"V006","2":"TRUE","3":"35","4":"97.22222"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
</section>
<section id="apply-exclusions-exclusion-3---2---1" class="level3">
<h3 class="anchored" data-anchor-id="apply-exclusions-exclusion-3---2---1">Apply exclusions (Exclusion 3 -> 2 -> 1)</h3>
<p><strong>Exclusions as preregistered</strong> 1) exclude implausible reaction times (implausible = react within first 25% of video time) 2) exclude those who fail to give a key-press response for > 20% of videos (i.e., more than 7 trials), indicate distraction or misunderstood instructions. 3) exclude participants > 20% misjudgment, i.e., < 80% accuracy</p>
</section>
<section id="exclusion-3" class="level3">
<h3 class="anchored" data-anchor-id="exclusion-3">Exclusion 3</h3>
<p>Exclude participants who got < 80% accuracy overall, i.e., judged 8 videos wrong</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="#cb13-1" aria-hidden="true" tabindex="-1"></a>low_accuracy_participants <span class="ot"><-</span> accuracy_for_each_participant <span class="sc">|></span> <span class="fu">filter</span>(percent_accuracy <span class="sc"><</span> <span class="dv">80</span>)</span>
<span id="cb13-2"><a href="#cb13-2" aria-hidden="true" tabindex="-1"></a><span class="co"># excluding 3 people (so far)</span></span>
<span id="cb13-3"><a href="#cb13-3" aria-hidden="true" tabindex="-1"></a><span class="co"># participants V14, V39, V52 will be excluded</span></span>
<span id="cb13-4"><a href="#cb13-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-5"><a href="#cb13-5" aria-hidden="true" tabindex="-1"></a><span class="co"># copy the main df to play around</span></span>
<span id="cb13-6"><a href="#cb13-6" aria-hidden="true" tabindex="-1"></a>reactionTime_copy <span class="ot"><-</span> reactionTime</span>
<span id="cb13-7"><a href="#cb13-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb13-8"><a href="#cb13-8" aria-hidden="true" tabindex="-1"></a>reactionTime_copy <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">grepl</span>(<span class="st">'V014|V039|V052'</span>, participant))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
</section>
<section id="exclusion-2" class="level3">
<h3 class="anchored" data-anchor-id="exclusion-2">Exclusion 2</h3>
<p>Exclude participants who gave more than 7 NULL key-press responses</p>
<p>We can see that the highest number of NULL response (i.e., participants gave no key-press response during stimuli) was 3 trials. Nobody is excluded on Exclusion 2!</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="#cb14-1" aria-hidden="true" tabindex="-1"></a>na_in_response_time <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> </span>
<span id="cb14-2"><a href="#cb14-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">na_response_time =</span> <span class="sc">!</span><span class="fu">is.na</span>(reactionTime_copy<span class="sc">$</span>rt.adjusted)) <span class="sc">|></span> </span>
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(participant, na_response_time) <span class="sc">|></span> <span class="fu">count</span>() <span class="sc">|></span> </span>
<span id="cb14-4"><a href="#cb14-4" aria-hidden="true" tabindex="-1"></a> <span class="co"># if we </span></span>
<span id="cb14-5"><a href="#cb14-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(na_response_time <span class="sc">==</span> <span class="cn">FALSE</span>) <span class="sc">|></span> <span class="fu">arrange</span>(<span class="fu">desc</span>(n))</span>
<span id="cb14-6"><a href="#cb14-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb14-7"><a href="#cb14-7" aria-hidden="true" tabindex="-1"></a>rmarkdown<span class="sc">::</span><span class="fu">paged_table</span>(<span class="fu">head</span>(na_in_response_time))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output-display">
<div data-pagedtable="false">
<script data-pagedtable-source="" type="application/json">
{"columns":[{"label":["participant"],"name":[1],"type":["chr"],"align":["left"]},{"label":["na_response_time"],"name":[2],"type":["lgl"],"align":["right"]},{"label":["n"],"name":[3],"type":["int"],"align":["right"]}],"data":[{"1":"V024","2":"FALSE","3":"3"},{"1":"V004","2":"FALSE","3":"2"},{"1":"V015","2":"FALSE","3":"2"},{"1":"V036","2":"FALSE","3":"2"},{"1":"V003","2":"FALSE","3":"1"},{"1":"V006","2":"FALSE","3":"1"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
</div>
</div>
</section>
<section id="exclusion-1" class="level3">
<h3 class="anchored" data-anchor-id="exclusion-1">Exclusion 1</h3>
<p>Exclude implausible reaction times (replace with NA) Here we are excluding data, not participants.</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a>process_implausible_reaction_times <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> <span class="fu">select</span>(participant, trial_index, rt, pour_moment) <span class="sc">|></span> </span>
<span id="cb15-2"><a href="#cb15-2" aria-hidden="true" tabindex="-1"></a> <span class="co"># responding during first 25% of movement is considered implausible</span></span>
<span id="cb15-3"><a href="#cb15-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">implausible =</span> pour_moment<span class="sc">/</span><span class="dv">4</span>) <span class="sc">|></span> </span>
<span id="cb15-4"><a href="#cb15-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">rt_implausible =</span> <span class="fu">case_when</span>(rt <span class="sc"><</span>implausible <span class="sc">~</span> <span class="st">"replace_with_na"</span>, </span>
<span id="cb15-5"><a href="#cb15-5" aria-hidden="true" tabindex="-1"></a> rt <span class="sc">>=</span> implausible <span class="sc">~</span> <span class="st">"include"</span>))</span>
<span id="cb15-6"><a href="#cb15-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-7"><a href="#cb15-7" aria-hidden="true" tabindex="-1"></a><span class="co"># if we examine the column rt_implausible, we see that only 1 participant had 1 implausible</span></span>
<span id="cb15-8"><a href="#cb15-8" aria-hidden="true" tabindex="-1"></a>examine_implausble <span class="ot"><-</span> process_implausible_reaction_times <span class="sc">|></span> <span class="fu">filter</span>(rt_implausible <span class="sc">==</span> <span class="st">"replace_with_na"</span>)</span>
<span id="cb15-9"><a href="#cb15-9" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb15-10"><a href="#cb15-10" aria-hidden="true" tabindex="-1"></a><span class="co"># </span><span class="al">CAUTION</span><span class="co">: Dataframe modified in place. </span></span>
<span id="cb15-11"><a href="#cb15-11" aria-hidden="true" tabindex="-1"></a>reactionTime_copy <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> </span>
<span id="cb15-12"><a href="#cb15-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">rt =</span> <span class="fu">replace</span>(rt, participant<span class="sc">==</span><span class="st">"V015"</span> <span class="sc">&</span> trial_index<span class="sc">==</span><span class="dv">2</span>, <span class="cn">NA</span>), </span>
<span id="cb15-13"><a href="#cb15-13" aria-hidden="true" tabindex="-1"></a> <span class="at">rt.adjusted =</span> <span class="fu">replace</span>(rt.adjusted, participant<span class="sc">==</span><span class="st">"V015"</span> <span class="sc">&</span> trial_index<span class="sc">==</span><span class="dv">2</span>, <span class="cn">NA</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
</section>
<section id="treatment-of-late-responses-and-wrong-responses" class="level3">
<h3 class="anchored" data-anchor-id="treatment-of-late-responses-and-wrong-responses">Treatment of late responses and wrong responses</h3>
<p>Wrong responses become NAs</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="#cb16-1" aria-hidden="true" tabindex="-1"></a>reactionTime_remove_wrongResponse <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> </span>
<span id="cb16-2"><a href="#cb16-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">response_time_for_analysis =</span> <span class="fu">case_when</span>(accuracy <span class="sc">==</span> <span class="cn">FALSE</span> <span class="sc">~</span> <span class="cn">NA</span>,</span>
<span id="cb16-3"><a href="#cb16-3" aria-hidden="true" tabindex="-1"></a> accuracy <span class="sc">==</span> <span class="cn">TRUE</span> <span class="sc">~</span> rt.adjusted))</span>
<span id="cb16-4"><a href="#cb16-4" aria-hidden="true" tabindex="-1"></a><span class="co">#sum(!complete.cases(reactionTime_remove_wrongResponse$response_time_for_analysis))</span></span>
<span id="cb16-5"><a href="#cb16-5" aria-hidden="true" tabindex="-1"></a><span class="co"># out of 60 participants</span></span>
<span id="cb16-6"><a href="#cb16-6" aria-hidden="true" tabindex="-1"></a><span class="co"># 192 wrong responses removed out of 2161 trials</span></span>
<span id="cb16-7"><a href="#cb16-7" aria-hidden="true" tabindex="-1"></a><span class="co"># 8.8% of responses were wrong</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="#cb17-1" aria-hidden="true" tabindex="-1"></a>reactionTime_preprocess <span class="ot"><-</span> reactionTime_remove_wrongResponse <span class="sc">|></span></span>
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(stimulus <span class="sc">!=</span> <span class="st">"Practice_dog_medium"</span>) <span class="sc">|></span> </span>
<span id="cb17-3"><a href="#cb17-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span><span class="fu">c</span>(trial_index, rt, response, correct_answer, accuracy, pour_moment, </span>
<span id="cb17-4"><a href="#cb17-4" aria-hidden="true" tabindex="-1"></a> rt.adjusted)) <span class="sc">|></span> </span>
<span id="cb17-5"><a href="#cb17-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(participant, stimulus) <span class="sc">|></span> </span>
<span id="cb17-6"><a href="#cb17-6" aria-hidden="true" tabindex="-1"></a><span class="co"># calculate mean for 3 rounds of participants' response times</span></span>
<span id="cb17-7"><a href="#cb17-7" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mean_of_3_rounds =</span> <span class="fu">mean</span>(response_time_for_analysis, <span class="at">na.rm =</span> <span class="cn">TRUE</span>)) <span class="sc">|></span></span>
<span id="cb17-8"><a href="#cb17-8" aria-hidden="true" tabindex="-1"></a><span class="co"># filter(!is.nan(mean_of_3_rounds)) |> </span></span>
<span id="cb17-9"><a href="#cb17-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">select</span>(<span class="sc">-</span>response_time_for_analysis) <span class="sc">|></span> <span class="fu">distinct</span>() <span class="sc">|></span></span>
<span id="cb17-10"><a href="#cb17-10" aria-hidden="true" tabindex="-1"></a><span class="co"># after combining into mean, only 1 data point was NA</span></span>
<span id="cb17-11"><a href="#cb17-11" aria-hidden="true" tabindex="-1"></a><span class="co"># sum(!complete.cases(reactionTime_preprocess$mean_of_3_rounds)) # 1</span></span>
<span id="cb17-12"><a href="#cb17-12" aria-hidden="true" tabindex="-1"></a><span class="co"># create columns for different conditions, for plotting</span></span>
<span id="cb17-13"><a href="#cb17-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">agent =</span> <span class="fu">case_when</span>(</span>
<span id="cb17-14"><a href="#cb17-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Human"</span>) <span class="sc">~</span> <span class="st">"Human"</span>, </span>
<span id="cb17-15"><a href="#cb17-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Milo"</span>) <span class="sc">~</span> <span class="st">"Humanoid"</span>, </span>
<span id="cb17-16"><a href="#cb17-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Theo"</span>) <span class="sc">~</span> <span class="st">"Robotic Arm"</span>, </span>
<span id="cb17-17"><a href="#cb17-17" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span> </span>
<span id="cb17-18"><a href="#cb17-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">motion_type =</span> <span class="fu">case_when</span>(</span>
<span id="cb17-19"><a href="#cb17-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Bio"</span>) <span class="sc">~</span> <span class="st">"Biological"</span>,</span>
<span id="cb17-20"><a href="#cb17-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Nonbio"</span>) <span class="sc">~</span> <span class="st">"Nonbiological"</span>, </span>
<span id="cb17-21"><a href="#cb17-21" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span></span>
<span id="cb17-22"><a href="#cb17-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">outcome_type =</span> <span class="fu">case_when</span>(</span>
<span id="cb17-23"><a href="#cb17-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Correct"</span>) <span class="sc">~</span> <span class="st">"Correct"</span>, </span>
<span id="cb17-24"><a href="#cb17-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Spill"</span>) <span class="sc">~</span> <span class="st">"Error"</span></span>
<span id="cb17-25"><a href="#cb17-25" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span> <span class="fu">filter</span>(stimulus <span class="sc">!=</span> <span class="st">"Practice_medium_dog"</span>) <span class="sc">|></span> </span>
<span id="cb17-26"><a href="#cb17-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">factor</span>(stimulus, </span>
<span id="cb17-27"><a href="#cb17-27" aria-hidden="true" tabindex="-1"></a> <span class="at">levels=</span><span class="fu">c</span>(<span class="st">"TheoBioCorrect"</span>, <span class="st">"TheoBioSpill"</span>, </span>
<span id="cb17-28"><a href="#cb17-28" aria-hidden="true" tabindex="-1"></a> <span class="st">"TheoNonbioCorrect"</span>, <span class="st">"TheoNonbioSpill"</span>, </span>
<span id="cb17-29"><a href="#cb17-29" aria-hidden="true" tabindex="-1"></a> <span class="st">"MiloBioCorrect"</span>, <span class="st">"MiloBioSpill"</span>, </span>
<span id="cb17-30"><a href="#cb17-30" aria-hidden="true" tabindex="-1"></a> <span class="st">"MiloNonbioCorrect"</span>, <span class="st">"MiloNonbioSpill"</span>, </span>
<span id="cb17-31"><a href="#cb17-31" aria-hidden="true" tabindex="-1"></a> <span class="st">"HumanBioCorrect"</span>, <span class="st">"HumanBioSpill"</span>, </span>
<span id="cb17-32"><a href="#cb17-32" aria-hidden="true" tabindex="-1"></a> <span class="st">"HumanNonbioCorrect"</span>, <span class="st">"HumanNonbioSpill"</span>)))</span>
<span id="cb17-33"><a href="#cb17-33" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-34"><a href="#cb17-34" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-35"><a href="#cb17-35" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-36"><a href="#cb17-36" aria-hidden="true" tabindex="-1"></a>reactionTime_preprocess <span class="ot"><-</span> reactionTime_preprocess <span class="sc">|></span> </span>
<span id="cb17-37"><a href="#cb17-37" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mean_of_3_rounds =</span> <span class="fu">case_when</span>(mean_of_3_rounds <span class="sc"><</span> <span class="sc">-</span><span class="dv">200</span> <span class="sc">~</span> <span class="cn">NA</span>, </span>
<span id="cb17-38"><a href="#cb17-38" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> mean_of_3_rounds)) </span>
<span id="cb17-39"><a href="#cb17-39" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-40"><a href="#cb17-40" aria-hidden="true" tabindex="-1"></a><span class="co"># participants to be excluded due to late responses: 7 people</span></span>
<span id="cb17-41"><a href="#cb17-41" aria-hidden="true" tabindex="-1"></a><span class="co">#2, 4, 8, 16, 17, 32, 34</span></span>
<span id="cb17-42"><a href="#cb17-42" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-43"><a href="#cb17-43" aria-hidden="true" tabindex="-1"></a>reactionTime_preprocess <span class="ot"><-</span> reactionTime_preprocess <span class="sc">|></span> </span>
<span id="cb17-44"><a href="#cb17-44" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(<span class="sc">!</span>participant <span class="sc">%in%</span> <span class="fu">c</span>(<span class="st">"V002"</span>, <span class="st">"V004"</span>, <span class="st">"V008"</span>, </span>
<span id="cb17-45"><a href="#cb17-45" aria-hidden="true" tabindex="-1"></a> <span class="st">"V016"</span>, <span class="st">"V017"</span>, <span class="st">"V032"</span>, <span class="st">"V034"</span>))</span>
<span id="cb17-46"><a href="#cb17-46" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb17-47"><a href="#cb17-47" aria-hidden="true" tabindex="-1"></a><span class="fu">sum</span>(<span class="sc">!</span><span class="fu">complete.cases</span>(reactionTime_preprocess<span class="sc">$</span>mean_of_3_rounds)) <span class="co">#92</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 92</code></pre>
</div>
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb19"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb19-1"><a href="#cb19-1" aria-hidden="true" tabindex="-1"></a><span class="co">#52 participants remaining</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<p>Impute mean of each stimulus for the NAs</p>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb20"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb20-1"><a href="#cb20-1" aria-hidden="true" tabindex="-1"></a>reactionTime_impute <span class="ot"><-</span> reactionTime_preprocess <span class="sc">|></span> <span class="fu">group_by</span>(stimulus) <span class="sc">|></span> </span>
<span id="cb20-2"><a href="#cb20-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">stimulus_mean =</span> <span class="fu">mean</span>(mean_of_3_rounds, <span class="at">na.rm =</span> <span class="cn">TRUE</span>))</span>
<span id="cb20-3"><a href="#cb20-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-4"><a href="#cb20-4" aria-hidden="true" tabindex="-1"></a><span class="co"># HumanBioCorrect 141.0958333</span></span>
<span id="cb20-5"><a href="#cb20-5" aria-hidden="true" tabindex="-1"></a><span class="co"># HumanBioSpill 332.0512821</span></span>
<span id="cb20-6"><a href="#cb20-6" aria-hidden="true" tabindex="-1"></a><span class="co"># HumanNonbioCorrect 184.2254902</span></span>
<span id="cb20-7"><a href="#cb20-7" aria-hidden="true" tabindex="-1"></a><span class="co"># HumanNonbioSpill 321.3233333</span></span>
<span id="cb20-8"><a href="#cb20-8" aria-hidden="true" tabindex="-1"></a><span class="co"># </span></span>
<span id="cb20-9"><a href="#cb20-9" aria-hidden="true" tabindex="-1"></a><span class="co"># MiloBioCorrect 413.3137255</span></span>
<span id="cb20-10"><a href="#cb20-10" aria-hidden="true" tabindex="-1"></a><span class="co"># MiloBioSpill 542.9198718</span></span>
<span id="cb20-11"><a href="#cb20-11" aria-hidden="true" tabindex="-1"></a><span class="co"># MiloNonbioCorrect 16.7849462</span></span>
<span id="cb20-12"><a href="#cb20-12" aria-hidden="true" tabindex="-1"></a><span class="co"># MiloNonbioSpill 0.7849462</span></span>
<span id="cb20-13"><a href="#cb20-13" aria-hidden="true" tabindex="-1"></a><span class="co"># </span></span>
<span id="cb20-14"><a href="#cb20-14" aria-hidden="true" tabindex="-1"></a><span class="co"># TheoBioCorrect 373.8472222</span></span>
<span id="cb20-15"><a href="#cb20-15" aria-hidden="true" tabindex="-1"></a><span class="co"># TheoBioSpill 520.4519231</span></span>
<span id="cb20-16"><a href="#cb20-16" aria-hidden="true" tabindex="-1"></a><span class="co"># TheoNonbioCorrect 110.2156863</span></span>
<span id="cb20-17"><a href="#cb20-17" aria-hidden="true" tabindex="-1"></a><span class="co"># TheoNonbioSpill 110.9000000</span></span>
<span id="cb20-18"><a href="#cb20-18" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb20-19"><a href="#cb20-19" aria-hidden="true" tabindex="-1"></a>IQR <span class="ot"><-</span> <span class="fu">IQR</span>(reactionTime_preprocess<span class="sc">$</span>mean_of_3_rounds, <span class="at">na.rm =</span> T) <span class="co">#414.3401</span></span>
<span id="cb20-20"><a href="#cb20-20" aria-hidden="true" tabindex="-1"></a>(<span class="fl">1.5</span><span class="sc">*</span>IQR) <span class="co">#668.5</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 669.375</code></pre>
</div>
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb22"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb22-1"><a href="#cb22-1" aria-hidden="true" tabindex="-1"></a>Q1<span class="ot"><-</span> <span class="fu">quantile</span>(reactionTime_preprocess<span class="sc">$</span>mean_of_3_rounds, <span class="fl">0.25</span>, <span class="at">na.rm =</span>T) <span class="co"># 37.66667 </span></span>
<span id="cb22-2"><a href="#cb22-2" aria-hidden="true" tabindex="-1"></a>Q3<span class="ot"><-</span> <span class="fu">quantile</span>(reactionTime_preprocess<span class="sc">$</span>mean_of_3_rounds, <span class="fl">0.75</span>, <span class="at">na.rm =</span>T) <span class="co"># 483.3333</span></span>
<span id="cb22-3"><a href="#cb22-3" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb22-4"><a href="#cb22-4" aria-hidden="true" tabindex="-1"></a>reactionTime_preprocess_imputed <span class="ot"><-</span> reactionTime_preprocess <span class="sc">|></span> </span>
<span id="cb22-5"><a href="#cb22-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mean_of_3_rounds =</span> <span class="fu">case_when</span>(mean_of_3_rounds <span class="sc">></span> <span class="fl">668.5</span> <span class="sc">~</span> <span class="cn">NA</span>, </span>
<span id="cb22-6"><a href="#cb22-6" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> mean_of_3_rounds)) </span>
<span id="cb22-7"><a href="#cb22-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb22-8"><a href="#cb22-8" aria-hidden="true" tabindex="-1"></a><span class="co"># Note: Before imputation, I had done the plotting. Uncomment the following lines 425-426 to create the data file (to run in ReactionTimeAnalysis.qmd)</span></span>
<span id="cb22-9"><a href="#cb22-9" aria-hidden="true" tabindex="-1"></a><span class="co"># plotting_reactionTime <- reactionTime_preprocess_imputed</span></span>
<span id="cb22-10"><a href="#cb22-10" aria-hidden="true" tabindex="-1"></a><span class="co"># write_csv(plotting_reactionTime, "plottingReactionTime.csv") </span></span>
<span id="cb22-11"><a href="#cb22-11" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb22-12"><a href="#cb22-12" aria-hidden="true" tabindex="-1"></a>reactionTime_preprocess_imputed <span class="ot"><-</span> reactionTime_preprocess_imputed <span class="sc">|></span></span>
<span id="cb22-13"><a href="#cb22-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">mean_of_3_rounds =</span> <span class="fu">case_when</span>(</span>
<span id="cb22-14"><a href="#cb22-14" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"HumanBioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">141.0958333</span>,</span>
<span id="cb22-15"><a href="#cb22-15" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"HumanBioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">332.0512821</span>, </span>
<span id="cb22-16"><a href="#cb22-16" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"HumanNonbioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">184.2254902</span>,</span>
<span id="cb22-17"><a href="#cb22-17" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"HumanNonbioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">321.3233333</span>,</span>
<span id="cb22-18"><a href="#cb22-18" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"MiloBioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">413.3137255</span>, </span>
<span id="cb22-19"><a href="#cb22-19" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"MiloBioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">542.9198718</span>,</span>
<span id="cb22-20"><a href="#cb22-20" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"MiloNonbioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">16.7849462</span>,</span>
<span id="cb22-21"><a href="#cb22-21" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"MiloNonbioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">0.7849462</span>, </span>
<span id="cb22-22"><a href="#cb22-22" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"TheoBioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">373.8472222</span>, </span>
<span id="cb22-23"><a href="#cb22-23" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"TheoBioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">520.4519231</span>, </span>
<span id="cb22-24"><a href="#cb22-24" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"TheoNonbioCorrect"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">110.2156863</span>, </span>
<span id="cb22-25"><a href="#cb22-25" aria-hidden="true" tabindex="-1"></a> stimulus <span class="sc">==</span> <span class="st">"TheoNonbioSpill"</span> <span class="sc">&&</span> <span class="fu">is.na</span>(mean_of_3_rounds) <span class="sc">~</span> <span class="fl">110.9</span>, </span>
<span id="cb22-26"><a href="#cb22-26" aria-hidden="true" tabindex="-1"></a> <span class="cn">TRUE</span> <span class="sc">~</span> mean_of_3_rounds))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<div class="cell">
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb23"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb23-1"><a href="#cb23-1" aria-hidden="true" tabindex="-1"></a><span class="fu">mean</span>(reactionTime_preprocess_imputed<span class="sc">$</span>mean_of_3_rounds, <span class="at">na.rm =</span> <span class="cn">TRUE</span>) <span class="co"># 255.6595</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 210.7072</code></pre>
</div>
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb25"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb25-1"><a href="#cb25-1" aria-hidden="true" tabindex="-1"></a><span class="fu">median</span>(reactionTime_preprocess_imputed<span class="sc">$</span>mean_of_3_rounds, <span class="at">na.rm =</span> <span class="cn">TRUE</span>) <span class="co">#186</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
<div class="cell-output cell-output-stdout">
<pre><code>[1] 184.6667</code></pre>
</div>
<details open="">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb27"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb27-1"><a href="#cb27-1" aria-hidden="true" tabindex="-1"></a><span class="co">#sum(!complete.cases(reactionTime_preprocess_imputed$mean_of_3_rounds)) </span></span>
<span id="cb27-2"><a href="#cb27-2" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb27-3"><a href="#cb27-3" aria-hidden="true" tabindex="-1"></a>standard_error <span class="ot"><-</span> <span class="cf">function</span>(x) {</span>
<span id="cb27-4"><a href="#cb27-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">sd</span>(x)<span class="sc">/</span><span class="fu">sqrt</span>(<span class="fu">length</span>(x))</span>
<span id="cb27-5"><a href="#cb27-5" aria-hidden="true" tabindex="-1"></a> }</span>
<span id="cb27-6"><a href="#cb27-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb27-7"><a href="#cb27-7" aria-hidden="true" tabindex="-1"></a>summary_statistics <span class="ot"><-</span> reactionTime_preprocess_imputed <span class="sc">|></span></span>
<span id="cb27-8"><a href="#cb27-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(stimulus) <span class="sc">|></span></span>
<span id="cb27-9"><a href="#cb27-9" aria-hidden="true" tabindex="-1"></a> <span class="fu">summarise</span>(<span class="at">mean =</span> <span class="fu">mean</span>(mean_of_3_rounds, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb27-10"><a href="#cb27-10" aria-hidden="true" tabindex="-1"></a> <span class="at">sd =</span> <span class="fu">sd</span>(mean_of_3_rounds, <span class="at">na.rm =</span> <span class="cn">TRUE</span>),</span>
<span id="cb27-11"><a href="#cb27-11" aria-hidden="true" tabindex="-1"></a> <span class="at">se =</span> sd<span class="sc">/</span><span class="fu">sqrt</span>(<span class="fu">length</span>(mean_of_3_rounds))) <span class="sc">|></span> </span>
<span id="cb27-12"><a href="#cb27-12" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">agent =</span> <span class="fu">case_when</span>(</span>
<span id="cb27-13"><a href="#cb27-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Human"</span>) <span class="sc">~</span> <span class="st">"Human"</span>, </span>
<span id="cb27-14"><a href="#cb27-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Milo"</span>) <span class="sc">~</span> <span class="st">"Humanoid"</span>, </span>
<span id="cb27-15"><a href="#cb27-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Theo"</span>) <span class="sc">~</span> <span class="st">"Robotic Arm"</span>, </span>
<span id="cb27-16"><a href="#cb27-16" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span> <span class="fu">mutate</span>(<span class="at">motion_type =</span> <span class="fu">case_when</span>(</span>
<span id="cb27-17"><a href="#cb27-17" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Bio"</span>) <span class="sc">~</span> <span class="st">"Biological"</span>,</span>
<span id="cb27-18"><a href="#cb27-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Nonbio"</span>) <span class="sc">~</span> <span class="st">"Nonbiological"</span>, </span>
<span id="cb27-19"><a href="#cb27-19" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span></span>
<span id="cb27-20"><a href="#cb27-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">outcome_type =</span> <span class="fu">case_when</span>(</span>
<span id="cb27-21"><a href="#cb27-21" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Correct"</span>) <span class="sc">~</span> <span class="st">"Correct"</span>, </span>
<span id="cb27-22"><a href="#cb27-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Spill"</span>) <span class="sc">~</span> <span class="st">"Error"</span>))</span>
<span id="cb27-23"><a href="#cb27-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb27-24"><a href="#cb27-24" aria-hidden="true" tabindex="-1"></a><span class="co">#write_csv(reactionTime_preprocess_imputed, "reactionTime_preprocess.csv")</span></span>
<span id="cb27-25"><a href="#cb27-25" aria-hidden="true" tabindex="-1"></a><span class="co">#write_csv(summary_statistics, "reactionTime_summary_statistics.csv")</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb28"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb28-1"><a href="#cb28-1" aria-hidden="true" tabindex="-1"></a>accuracy_by_condition_inTimeOnly <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> </span>
<span id="cb28-2"><a href="#cb28-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(stimulus <span class="sc">!=</span> <span class="st">"Practice_dog_medium"</span>) <span class="sc">|></span> <span class="fu">filter</span>(rt.adjusted <span class="sc">></span> <span class="dv">0</span>) <span class="sc">|></span> </span>
<span id="cb28-3"><a href="#cb28-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(stimulus, accuracy) <span class="sc">|></span> <span class="fu">count</span>() <span class="sc">|></span> </span>
<span id="cb28-4"><a href="#cb28-4" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(stimulus) <span class="sc">|></span> </span>
<span id="cb28-5"><a href="#cb28-5" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">percentage_n =</span> <span class="fu">round</span>( (n<span class="sc">/</span><span class="fu">sum</span>(n))<span class="sc">*</span><span class="dv">100</span>, <span class="at">digits=</span><span class="dv">1</span>) )</span>
<span id="cb28-6"><a href="#cb28-6" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb28-7"><a href="#cb28-7" aria-hidden="true" tabindex="-1"></a>accuracy_by_condition_inTimeOnly <span class="sc">|></span> </span>
<span id="cb28-8"><a href="#cb28-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">stimulus =</span> <span class="fu">factor</span>(stimulus, </span>
<span id="cb28-9"><a href="#cb28-9" aria-hidden="true" tabindex="-1"></a> <span class="at">levels=</span> <span class="fu">c</span>(<span class="st">"TheoBioCorrect"</span>, <span class="st">"TheoBioSpill"</span>, <span class="st">"TheoNonbioCorrect"</span>, <span class="st">"TheoNonbioSpill"</span>, </span>
<span id="cb28-10"><a href="#cb28-10" aria-hidden="true" tabindex="-1"></a> <span class="st">"MiloBioCorrect"</span>, <span class="st">"MiloBioSpill"</span>, <span class="st">"MiloNonbioCorrect"</span>, <span class="st">"MiloNonbioSpill"</span>, </span>
<span id="cb28-11"><a href="#cb28-11" aria-hidden="true" tabindex="-1"></a> <span class="st">"HumanBioCorrect"</span>, <span class="st">"HumanBioSpill"</span>, <span class="st">"HumanNonbioCorrect"</span>, <span class="st">"HumanNonbioSpill"</span>)</span>
<span id="cb28-12"><a href="#cb28-12" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span> </span>
<span id="cb28-13"><a href="#cb28-13" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">agent =</span> <span class="fu">case_when</span>(</span>
<span id="cb28-14"><a href="#cb28-14" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Human"</span>) <span class="sc">~</span> <span class="st">"Human"</span>, </span>
<span id="cb28-15"><a href="#cb28-15" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Milo"</span>) <span class="sc">~</span> <span class="st">"Humanoid"</span>, </span>
<span id="cb28-16"><a href="#cb28-16" aria-hidden="true" tabindex="-1"></a> <span class="fu">str_detect</span>(stimulus, <span class="st">"Theo"</span>) <span class="sc">~</span> <span class="st">"Robotic Arm"</span>, </span>
<span id="cb28-17"><a href="#cb28-17" aria-hidden="true" tabindex="-1"></a> )) <span class="sc">|></span> </span>
<span id="cb28-18"><a href="#cb28-18" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggplot</span>(<span class="fu">aes</span>(<span class="at">x=</span> <span class="fu">fct_rev</span>(stimulus), <span class="at">y =</span> n, <span class="at">fill =</span> accuracy, <span class="at">label =</span> <span class="fu">paste0</span>(percentage_n,<span class="st">"%"</span>))) <span class="sc">+</span></span>
<span id="cb28-19"><a href="#cb28-19" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_bar</span>(<span class="at">stat =</span> <span class="st">"identity"</span>, <span class="at">position =</span> <span class="st">'dodge'</span>, <span class="at">width =</span> .<span class="dv">6</span>) <span class="sc">+</span></span>
<span id="cb28-20"><a href="#cb28-20" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_text</span>(<span class="at">size =</span> <span class="dv">5</span>, <span class="at">hjust =</span> <span class="sc">-</span><span class="fl">0.5</span>,</span>
<span id="cb28-21"><a href="#cb28-21" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="fu">position_dodge</span>(<span class="at">width =</span> .<span class="dv">75</span>)) <span class="sc">+</span></span>
<span id="cb28-22"><a href="#cb28-22" aria-hidden="true" tabindex="-1"></a> <span class="fu">guides</span>(<span class="at">fill =</span> <span class="fu">guide_legend</span>(<span class="at">title=</span><span class="st">"Key-Press Response Accuracy"</span>, <span class="at">reverse=</span> <span class="cn">TRUE</span>)) <span class="sc">+</span> </span>
<span id="cb28-23"><a href="#cb28-23" aria-hidden="true" tabindex="-1"></a> <span class="fu">coord_flip</span>() <span class="sc">+</span></span>
<span id="cb28-24"><a href="#cb28-24" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_x_discrete</span>(<span class="at">name =</span> <span class="st">"Conditions"</span>, <span class="at">labels =</span> labels_reverse, <span class="at">expand =</span> <span class="fu">c</span>(<span class="fl">0.02</span>, <span class="dv">0</span>, .<span class="dv">08</span>, <span class="dv">0</span>)) <span class="sc">+</span></span>
<span id="cb28-25"><a href="#cb28-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_y_continuous</span>(<span class="at">name =</span> <span class="st">"Number of responses"</span>, <span class="at">expand =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">0</span>), <span class="at">limits =</span> <span class="fu">c</span>(<span class="dv">0</span>, <span class="dv">180</span>)) <span class="sc">+</span></span>
<span id="cb28-26"><a href="#cb28-26" aria-hidden="true" tabindex="-1"></a> <span class="fu">scale_fill_discrete</span>(<span class="at">labels=</span><span class="fu">c</span>(<span class="st">'Wrong Response'</span>, <span class="st">'Correct Response'</span>))<span class="sc">+</span></span>
<span id="cb28-27"><a href="#cb28-27" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_linedraw</span>() <span class="sc">+</span></span>
<span id="cb28-28"><a href="#cb28-28" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme</span>(<span class="at">plot.margin =</span> <span class="fu">margin</span>(<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>,<span class="dv">1</span>, <span class="st">"cm"</span>), </span>
<span id="cb28-29"><a href="#cb28-29" aria-hidden="true" tabindex="-1"></a> <span class="at">plot.title =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">22</span>), </span>
<span id="cb28-30"><a href="#cb28-30" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.title =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">18</span>),</span>
<span id="cb28-31"><a href="#cb28-31" aria-hidden="true" tabindex="-1"></a> <span class="at">axis.text=</span><span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">14</span>), </span>
<span id="cb28-32"><a href="#cb28-32" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.title =</span> <span class="fu">element_text</span>(<span class="at">size =</span> <span class="dv">14</span>, <span class="at">face=</span><span class="st">"bold"</span>),</span>
<span id="cb28-33"><a href="#cb28-33" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.text =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">10</span>, <span class="at">face=</span><span class="st">"bold"</span>), </span>
<span id="cb28-34"><a href="#cb28-34" aria-hidden="true" tabindex="-1"></a> <span class="at">strip.text.x =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="dv">16</span>, <span class="at">face=</span><span class="st">"bold"</span>), </span>
<span id="cb28-35"><a href="#cb28-35" aria-hidden="true" tabindex="-1"></a> <span class="at">legend.position=</span><span class="st">"bottom"</span>) <span class="sc">+</span> </span>
<span id="cb28-36"><a href="#cb28-36" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggtitle</span>(<span class="st">"How many key-presses were wrong? (Late responses EXCLUDED)"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
</section>
<section id="exploring-late-responses" class="level3">
<h3 class="anchored" data-anchor-id="exploring-late-responses">Exploring Late Responses</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb29"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb29-1"><a href="#cb29-1" aria-hidden="true" tabindex="-1"></a>late <span class="ot"><-</span> reactionTime_copy <span class="sc">|></span> </span>
<span id="cb29-2"><a href="#cb29-2" aria-hidden="true" tabindex="-1"></a> <span class="fu">filter</span>(stimulus <span class="sc">!=</span> <span class="st">"Practice_dog_medium"</span>) <span class="sc">|></span> </span>
<span id="cb29-3"><a href="#cb29-3" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">in_time_or_late_response =</span> <span class="fu">case_when</span>(predict_in_advance <span class="sc">>=</span> <span class="dv">0</span> <span class="sc">~</span> <span class="st">"in time"</span>, </span>
<span id="cb29-4"><a href="#cb29-4" aria-hidden="true" tabindex="-1"></a> predict_in_advance <span class="sc"><</span><span class="dv">0</span> <span class="sc">~</span> <span class="st">"late"</span>)) </span>
<span id="cb29-5"><a href="#cb29-5" aria-hidden="true" tabindex="-1"></a><span class="co">#count how many in-time, late, NA</span></span>
<span id="cb29-6"><a href="#cb29-6" aria-hidden="true" tabindex="-1"></a>late_count <span class="ot"><-</span> late <span class="sc">|></span> <span class="fu">group_by</span>(stimulus, in_time_or_late_response) <span class="sc">|></span> <span class="fu">count</span>()</span>
<span id="cb29-7"><a href="#cb29-7" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb29-8"><a href="#cb29-8" aria-hidden="true" tabindex="-1"></a><span class="co">#print(late_count)</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</details>
</div>
</section>
<section id="half-violin" class="level3">
<h3 class="anchored" data-anchor-id="half-violin">Half violin</h3>
<div class="cell">
<details>
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb30"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb30-1"><a href="#cb30-1" aria-hidden="true" tabindex="-1"></a><span class="st">"%||%"</span> <span class="ot"><-</span> <span class="cf">function</span>(a, b) {</span>
<span id="cb30-2"><a href="#cb30-2" aria-hidden="true" tabindex="-1"></a> <span class="cf">if</span> (<span class="sc">!</span><span class="fu">is.null</span>(a)) a <span class="cf">else</span> b</span>
<span id="cb30-3"><a href="#cb30-3" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb30-4"><a href="#cb30-4" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb30-5"><a href="#cb30-5" aria-hidden="true" tabindex="-1"></a>geom_flat_violin <span class="ot"><-</span> <span class="cf">function</span>(<span class="at">mapping =</span> <span class="cn">NULL</span>, <span class="at">data =</span> <span class="cn">NULL</span>, <span class="at">stat =</span> <span class="st">"ydensity"</span>,</span>
<span id="cb30-6"><a href="#cb30-6" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> <span class="st">"dodge"</span>, <span class="at">trim =</span> <span class="cn">TRUE</span>, <span class="at">scale =</span> <span class="st">"area"</span>,</span>
<span id="cb30-7"><a href="#cb30-7" aria-hidden="true" tabindex="-1"></a> <span class="at">show.legend =</span> <span class="cn">NA</span>, <span class="at">inherit.aes =</span> <span class="cn">TRUE</span>, ...) {</span>
<span id="cb30-8"><a href="#cb30-8" aria-hidden="true" tabindex="-1"></a> <span class="fu">layer</span>(</span>
<span id="cb30-9"><a href="#cb30-9" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> data,</span>
<span id="cb30-10"><a href="#cb30-10" aria-hidden="true" tabindex="-1"></a> <span class="at">mapping =</span> mapping,</span>
<span id="cb30-11"><a href="#cb30-11" aria-hidden="true" tabindex="-1"></a> <span class="at">stat =</span> stat,</span>
<span id="cb30-12"><a href="#cb30-12" aria-hidden="true" tabindex="-1"></a> <span class="at">geom =</span> GeomFlatViolin,</span>
<span id="cb30-13"><a href="#cb30-13" aria-hidden="true" tabindex="-1"></a> <span class="at">position =</span> position,</span>
<span id="cb30-14"><a href="#cb30-14" aria-hidden="true" tabindex="-1"></a> <span class="at">show.legend =</span> show.legend,</span>
<span id="cb30-15"><a href="#cb30-15" aria-hidden="true" tabindex="-1"></a> <span class="at">inherit.aes =</span> inherit.aes,</span>
<span id="cb30-16"><a href="#cb30-16" aria-hidden="true" tabindex="-1"></a> <span class="at">params =</span> <span class="fu">list</span>(</span>
<span id="cb30-17"><a href="#cb30-17" aria-hidden="true" tabindex="-1"></a> <span class="at">trim =</span> trim,</span>
<span id="cb30-18"><a href="#cb30-18" aria-hidden="true" tabindex="-1"></a> <span class="at">scale =</span> scale,</span>
<span id="cb30-19"><a href="#cb30-19" aria-hidden="true" tabindex="-1"></a> ...</span>
<span id="cb30-20"><a href="#cb30-20" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb30-21"><a href="#cb30-21" aria-hidden="true" tabindex="-1"></a> )</span>
<span id="cb30-22"><a href="#cb30-22" aria-hidden="true" tabindex="-1"></a>}</span>
<span id="cb30-23"><a href="#cb30-23" aria-hidden="true" tabindex="-1"></a></span>
<span id="cb30-24"><a href="#cb30-24" aria-hidden="true" tabindex="-1"></a>GeomFlatViolin <span class="ot"><-</span></span>
<span id="cb30-25"><a href="#cb30-25" aria-hidden="true" tabindex="-1"></a> <span class="fu">ggproto</span>(<span class="st">"Violinist"</span>, Geom,</span>
<span id="cb30-26"><a href="#cb30-26" aria-hidden="true" tabindex="-1"></a> <span class="at">setup_data =</span> <span class="cf">function</span>(data, params) {</span>
<span id="cb30-27"><a href="#cb30-27" aria-hidden="true" tabindex="-1"></a> data<span class="sc">$</span>width <span class="ot"><-</span> data<span class="sc">$</span>width <span class="sc">%||%</span></span>
<span id="cb30-28"><a href="#cb30-28" aria-hidden="true" tabindex="-1"></a> params<span class="sc">$</span>width <span class="sc">%||%</span> (<span class="fu">resolution</span>(data<span class="sc">$</span>x, <span class="cn">FALSE</span>) <span class="sc">*</span> <span class="fl">0.9</span>)</span>
<span id="cb30-29"><a href="#cb30-29" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb30-30"><a href="#cb30-30" aria-hidden="true" tabindex="-1"></a> <span class="co"># ymin, ymax, xmin, and xmax define the bounding rectangle for each group</span></span>
<span id="cb30-31"><a href="#cb30-31" aria-hidden="true" tabindex="-1"></a> data <span class="sc">%>%</span></span>
<span id="cb30-32"><a href="#cb30-32" aria-hidden="true" tabindex="-1"></a> <span class="fu">group_by</span>(group) <span class="sc">%>%</span></span>
<span id="cb30-33"><a href="#cb30-33" aria-hidden="true" tabindex="-1"></a> <span class="fu">mutate</span>(<span class="at">ymin =</span> <span class="fu">min</span>(y),</span>
<span id="cb30-34"><a href="#cb30-34" aria-hidden="true" tabindex="-1"></a> <span class="at">ymax =</span> <span class="fu">max</span>(y),</span>
<span id="cb30-35"><a href="#cb30-35" aria-hidden="true" tabindex="-1"></a> <span class="at">xmin =</span> x,</span>
<span id="cb30-36"><a href="#cb30-36" aria-hidden="true" tabindex="-1"></a> <span class="at">xmax =</span> x <span class="sc">+</span> width <span class="sc">/</span> <span class="dv">2</span>)</span>
<span id="cb30-37"><a href="#cb30-37" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb30-38"><a href="#cb30-38" aria-hidden="true" tabindex="-1"></a> },</span>
<span id="cb30-39"><a href="#cb30-39" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb30-40"><a href="#cb30-40" aria-hidden="true" tabindex="-1"></a> <span class="at">draw_group =</span> <span class="cf">function</span>(data, panel_scales, coord) {</span>
<span id="cb30-41"><a href="#cb30-41" aria-hidden="true" tabindex="-1"></a> <span class="co"># Find the points for the line to go all the way around</span></span>
<span id="cb30-42"><a href="#cb30-42" aria-hidden="true" tabindex="-1"></a> data <span class="ot"><-</span> <span class="fu">transform</span>(data, <span class="at">xminv =</span> x,</span>
<span id="cb30-43"><a href="#cb30-43" aria-hidden="true" tabindex="-1"></a> <span class="at">xmaxv =</span> x <span class="sc">+</span> violinwidth <span class="sc">*</span> (xmax <span class="sc">-</span> x))</span>
<span id="cb30-44"><a href="#cb30-44" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb30-45"><a href="#cb30-45" aria-hidden="true" tabindex="-1"></a> <span class="co"># Make sure it's sorted properly to draw the outline</span></span>
<span id="cb30-46"><a href="#cb30-46" aria-hidden="true" tabindex="-1"></a> newdata <span class="ot"><-</span> <span class="fu">rbind</span>(plyr<span class="sc">::</span><span class="fu">arrange</span>(<span class="fu">transform</span>(data, <span class="at">x =</span> xminv), y),</span>
<span id="cb30-47"><a href="#cb30-47" aria-hidden="true" tabindex="-1"></a> plyr<span class="sc">::</span><span class="fu">arrange</span>(<span class="fu">transform</span>(data, <span class="at">x =</span> xmaxv), <span class="sc">-</span>y))</span>
<span id="cb30-48"><a href="#cb30-48" aria-hidden="true" tabindex="-1"></a> </span>
<span id="cb30-49"><a href="#cb30-49" aria-hidden="true" tabindex="-1"></a> <span class="co"># Close the polygon: set first and last point the same</span></span>
<span id="cb30-50"><a href="#cb30-50" aria-hidden="true" tabindex="-1"></a> <span class="co"># Needed for coord_polar and such</span></span>
<span id="cb30-51"><a href="#cb30-51" aria-hidden="true" tabindex="-1"></a> newdata <span class="ot"><-</span> <span class="fu">rbind</span>(newdata, newdata[<span class="dv">1</span>,])</span>
<span id="cb30-52"><a href="#cb30-52" aria-hidden="true" tabindex="-1"></a> </span>