#https://modelsummary.com/articles/datasummary.htmldatasummary(vx*vb~Mean+SD+Histogram, data =testAvg)
vb
Mean
SD
Histogram
vx
100-300
592.33
316.56
▂▆▇▄▂▃▂▁▁
350-550
715.10
280.69
▁▅▇▇▅▃▂▁▁▁
600-800
824.26
258.15
▁▅▅▇▅▃▂▁▁▁
800-1000
1038.72
252.85
▁▃▆▆▇▃▂▁▁
1000-1200
1176.96
287.31
▁▂▄▆▇▅▃▂▁▁
1200-1400
1288.65
325.64
▂▄▅▇▅▃▁▂▁
datasummary(vx*vb*condit~Mean+SD+Histogram, data =testAvg)
vb
condit
Mean
SD
Histogram
vx
100-300
Constant
522.83
245.10
▁▅▅▇▄▃▂▁▂▁
Varied
665.49
365.02
▄▇▇▂▁▅▃▂▂▁
350-550
Constant
660.61
224.30
▁▃▅▇▇▃▂▂ ▁
Varied
772.47
321.45
▄▄▇▄▃▂▁▂▁▂
600-800
Constant
771.75
210.50
▁▄▆▃▇▄▂▁▂▁
Varied
879.54
291.57
▃▄▄▇▇▄▂▁▂▂
800-1000
Constant
1008.76
254.58
▂▄▇▆▅▂▁▁
Varied
1070.25
248.79
▁▂▅▃▅▇▄▃▁▂
1000-1200
Constant
1173.42
307.89
▁▂▅▆▇▆▃▂ ▃
Varied
1180.70
265.92
▁▂▄▆▇▆▃▃▁▃
1200-1400
Constant
1306.99
355.81
▂▄▆▇▄▃▁▃▁
Varied
1269.34
291.65
▂▄▂▅▆▇▄▂▁
datasummary(vx*vb*condit~Mean+SD+Histogram, data =test)
vb
condit
Mean
SD
Histogram
vx
100-300
Constant
524.28
326.84
▅▇▆▃▂▁▁
Varied
663.96
448.23
▅▇▄▃▂▂▁
350-550
Constant
658.76
302.96
▁▅▇▆▄▂▁
Varied
767.77
401.84
▂▇▆▄▃▂▁▁
600-800
Constant
770.39
299.50
▁▄▇▆▄▃▁
Varied
876.49
389.91
▁▆▇▆▄▃▂▁
800-1000
Constant
1000.54
356.85
▃▇▆▃▂▁
Varied
1063.94
369.78
▂▅▆▇▄▃▁
1000-1200
Constant
1166.65
429.75
▁▂▅▇▄▂▁
Varied
1180.43
372.22
▁▄▇▇▅▂▁
1200-1400
Constant
1282.55
482.56
▁▂▄▇▆▃▂▂▁
Varied
1264.68
411.92
▁▂▄▇▆▄▃▁
datasummary_crosstab(vb~condit*tOrder, data =test)
Constant
Varied
vb
testFirst
trainFirst
testFirst
trainFirst
All
100-300
N
671
493
564
544
2272
% row
29.5
21.7
24.8
23.9
100.0
350-550
N
679
499
573
543
2294
% row
29.6
21.8
25.0
23.7
100.0
600-800
N
673
497
573
543
2286
% row
29.4
21.7
25.1
23.8
100.0
800-1000
N
265
197
224
214
900
% row
29.4
21.9
24.9
23.8
100.0
1000-1200
N
250
190
228
206
874
% row
28.6
21.7
26.1
23.6
100.0
1200-1400
N
244
187
226
208
865
% row
28.2
21.6
26.1
24.0
100.0
All
N
2782
2063
2388
2258
9491
% row
29.3
21.7
25.2
23.8
100.0
datasummary_crosstab(result~condit, statistic =1~Percent("col"), data =test)
result
Constant
Varied
Hit
% col
25.0
21.4
Over
% col
52.5
59.0
Under
% col
22.6
19.7
All
% col
100.0
100.0
datasummary_crosstab(result~condit*vb, statistic =1~Percent("col"), data =test)
Constant
Varied
result
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
Hit
% col
25.3
24.7
28.1
28.1
21.8
16.2
20.1
24.7
20.7
19.4
21.0
19.8
Over
% col
71.6
60.1
40.4
42.4
41.6
34.6
77.9
63.7
51.8
53.9
47.2
33.9
Under
% col
3.2
15.2
31.5
29.4
36.6
49.2
2.0
11.6
27.5
26.7
31.8
46.3
All
% col
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
100.0
datasummary(vx+dist+vy~mean*condit*vb, data =e1)
Constant
Varied
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
vx
509.05
644.81
760.25
927.21
1166.65
1282.55
611.22
733.03
848.60
1012.53
1103.13
1185.13
dist
240.32
178.74
145.34
137.17
232.80
287.09
338.27
258.83
215.48
204.68
204.51
260.39
vy
81.42
115.76
157.74
206.72
244.71
276.07
92.91
126.21
158.92
189.22
209.89
230.23
datasummary(Heading("X Velocity")*vx+Heading("Abs. Deviation")*dist+vy~mean*condit*vb, data =e1)
Constant
Varied
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
X Velocity
509.05
644.81
760.25
927.21
1166.65
1282.55
611.22
733.03
848.60
1012.53
1103.13
1185.13
Abs. Deviation
240.32
178.74
145.34
137.17
232.80
287.09
338.27
258.83
215.48
204.68
204.51
260.39
vy
81.42
115.76
157.74
206.72
244.71
276.07
92.91
126.21
158.92
189.22
209.89
230.23
datasummary(vx+dist~Factor(condit)*(mean+sd), data =test)
Constant
Varied
mean
sd
mean
sd
vx
787.61
423.16
882.02
452.04
dist
207.76
254.08
279.52
329.31
datasummary(vx+dist~Factor(condit)*vb*(mean+sd), data =test)
Constant
Varied
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
mean
sd
vx
524.28
326.84
658.76
302.96
770.39
299.50
1000.54
356.85
1166.65
429.75
1282.55
482.56
663.96
448.23
767.77
401.84
876.49
389.91
1063.94
369.78
1180.43
372.22
1264.68
411.92
dist
253.85
297.56
190.57
229.23
150.01
184.41
183.91
241.99
232.80
282.14
287.09
290.25
385.65
426.23
285.04
340.41
234.14
269.93
220.87
248.39
207.87
226.43
241.93
234.68
datasummary(vb*Factor(condit)*(mean+sd)~vx+dist, data =test)
vb
condit
vx
dist
100-300
Constant
mean
524.28
253.85
sd
326.84
297.56
Varied
mean
663.96
385.65
sd
448.23
426.23
350-550
Constant
mean
658.76
190.57
sd
302.96
229.23
Varied
mean
767.77
285.04
sd
401.84
340.41
600-800
Constant
mean
770.39
150.01
sd
299.50
184.41
Varied
mean
876.49
234.14
sd
389.91
269.93
800-1000
Constant
mean
1000.54
183.91
sd
356.85
241.99
Varied
mean
1063.94
220.87
sd
369.78
248.39
1000-1200
Constant
mean
1166.65
232.80
sd
429.75
282.14
Varied
mean
1180.43
207.87
sd
372.22
226.43
1200-1400
Constant
mean
1282.55
287.09
sd
482.56
290.25
Varied
mean
1264.68
241.93
sd
411.92
234.68
tmp<-mtcars[, c("mpg", "hp")]# create a list with individual variables# remove missing and rescaletmp_list<-lapply(tmp, na.omit)tmp_list<-lapply(tmp_list, scale)# create a table with `datasummary`# add a histogram with column_spec and spec_hist# add a boxplot with colun_spec and spec_boxemptycol=function(x)" "datasummary(mpg+hp~Mean+SD+Heading("Boxplot")*emptycol+Heading("Histogram")*emptycol, output ="kableExtra", data =tmp)%>%kableExtra::column_spec(column =4, image =spec_boxplot(tmp_list))%>%kableExtra::column_spec(column =5, image =spec_hist(tmp_list))
Mean
SD
Boxplot
Histogram
mpg
20.09
6.03
hp
146.69
68.56
tmp_list<-lapply(test|>ungroup()|>select(vx,vb,condit), na.omit)# scale only numeric columns - not all are numeric so can't just lapplytmp_list<-map(tmp_list, ~if(is.numeric(.x))scale(.x)else.x)ts=test|>ungroup()|>select(vx,vb,condit)|>mutate(vxScale=scale(vx)[,1])datasummary(vxScale*vb~Mean+Histogram, data=ts, output ="kableExtra")%>%kableExtra::column_spec(column =4, image =spec_boxplot(ts))
Warning in ensure_len_html(image, nrows, "image"): The number of provided
values in image does not equal to the number of rows.
Warning in ensure_len_html(image, nrows, "image"): The number of provided
values in image does not equal to the number of rows.
vb
condit
Mean
Histogram
vx
100-300
Constant
524.28
▅▇▆▃▂▁▁
Varied
663.96
▅▇▄▃▂▂▁
350-550
Constant
658.76
▁▅▇▆▄▂▁
Varied
767.77
▂▇▆▄▃▂▁▁
600-800
Constant
770.39
▁▄▇▆▄▃▁
Varied
876.49
▁▆▇▆▄▃▂▁
800-1000
Constant
1000.54
▃▇▆▃▂▁
Varied
1063.94
▂▅▆▇▄▃▁
1000-1200
Constant
1166.65
▁▂▅▇▄▂▁
Varied
1180.43
▁▄▇▇▅▂▁
1200-1400
Constant
1282.55
▁▂▄▇▆▃▂▂▁
Varied
1264.68
▁▂▄▇▆▄▃▁
cap<-"Testing - No Feedback"f<-(`Condit`=condit)~(` `=vx)*(`Distribution`=Histogram)+vx*vb*((`Avg.`=Mean)*Arguments(fmt='%.0f')+(`SD`=SD)*Arguments(fmt='%.0f'))datasummary(f, data =test, output ='gt', title =cap, notes ='Artwork by @Thomas', sparse_header =TRUE)
Testing - No Feedback
Condit
Distribution
100-300
350-550
600-800
800-1000
1000-1200
1200-1400
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Constant
▃▇▇▄▂▁
524
327
659
303
770
300
1001
357
1167
430
1283
483
Varied
▃▇▇▆▄▃▁
664
448
768
402
876
390
1064
370
1180
372
1265
412
Artwork by @Thomas
f<-(`Band`=vb)~(` `=vx)*(`Distribution`=Histogram)+vx*condit*((`Avg.`=Mean)*Arguments(fmt='%.0f')+(`SD`=SD)*Arguments(fmt='%.0f'))datasummary(f, data =test, output ='gt', title =cap, notes ='Artwork by @Thomas', sparse_header =TRUE)
Testing - No Feedback
Band
Distribution
Constant
Varied
Avg.
SD
Avg.
SD
100-300
▆▇▄▂▁▁
524
327
664
448
350-550
▂▇▇▅▃▁▁
659
303
768
402
600-800
▁▅▇▅▃▂▁
770
300
876
390
800-1000
▁▃▇▇▄▂▁
1001
357
1064
370
1000-1200
▂▅▇▅▂▁
1167
430
1180
372
1200-1400
▂▄▇▆▄▂▁
1283
483
1265
412
Artwork by @Thomas
f<-(`Band`=vb)~(` `=vx)*(`Distribution`=Histogram)+vx*condit*expMode2*((`Avg.`=Mean)*Arguments(fmt='%.0f')+(`SD`=SD)*Arguments(fmt='%.0f'))datasummary(f, data =e1, output ='gt', sparse_header =TRUE)
Constant
Varied
Train
Train-Nf
Test
Test-Fb
Train
Train-Nf
Test
Test-Fb
Band
Distribution
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
Avg.
SD
100-300
▇▇▄▂▁▁
599
368
524
327
395
265
652
413
664
448
484
406
350-550
▂▇▅▂▁▁
714
332
659
303
554
265
754
395
768
402
655
379
600-800
▁▅▇▄▂▁
816
321
770
300
688
267
882
393
876
390
770
354
800-1000
▂▇▄▁
922
298
1001
357
1002
369
1064
370
1000-1200
▂▆▇▃▁
1167
430
1087
383
1180
372
1200-1400
▁▂▅▇▅▂▁
1283
483
1169
430
1265
412
f<-(`Band`=vb)*expMode2~vx*condit*((`Avg.`=Mean)*Arguments(fmt='%.0f')+(`SD`=SD)*Arguments(fmt='%.0f'))datasummary(f, data =e1, output ='gt', sparse_header =TRUE)
Band
expMode2
Constant
Varied
Avg.
SD
Avg.
SD
100-300
Train
Train-Nf
599
368
652
413
Test
524
327
664
448
Test-Fb
395
265
484
406
350-550
Train
Train-Nf
714
332
754
395
Test
659
303
768
402
Test-Fb
554
265
655
379
600-800
Train
Train-Nf
816
321
882
393
Test
770
300
876
390
Test-Fb
688
267
770
354
800-1000
Train
922
298
1002
369
Train-Nf
Test
1001
357
1064
370
Test-Fb
1000-1200
Train
1087
383
Train-Nf
Test
1167
430
1180
372
Test-Fb
1200-1400
Train
1169
430
Train-Nf
Test
1283
483
1265
412
Test-Fb
f<-(`Band`=vb)*expMode2~dist*condit*((`Avg.`=Mean)*Arguments(fmt='%.0f'))datasummary(f, data =e1, output ='gt', sparse_header =TRUE)
Band
expMode2
Constant
Varied
Avg.
Avg.
100-300
Train
Train-Nf
321
374
Test
254
386
Test-Fb
138
225
350-550
Train
Train-Nf
229
281
Test
191
285
Test-Fb
110
194
600-800
Train
Train-Nf
169
231
Test
150
234
Test-Fb
115
169
800-1000
Train
134
201
Train-Nf
Test
184
221
Test-Fb
1000-1200
Train
204
Train-Nf
Test
233
208
Test-Fb
1200-1400
Train
264
Train-Nf
Test
287
242
Test-Fb
```{r}#| label: test vx table#| tbl-cap: "Testing - No Feedback"#| tbl-subcap: ["Constant Testing - X Velocity", "Varied Testing - X Velocity"]#| layout-ncol: 2result <- test_summary_table(test, "vx", mfun = list(mean = mean, median = median, sd = sd))result$constant #|> kable_styling(full_width = F)result$varied #|> kable_styling(full_width = F)```
e1|>filter(expMode%in%c("test-Nf","test-train-nf"))|>ggplot(aes(x =vb, y =dist,fill=condit))+stat_summary(geom ="bar", position=position_dodge(), fun =mean)+stat_summary(geom ="errorbar", position=position_dodge(.9), fun.data =mean_se, width =.4, alpha =.7)
e1|>filter(expMode%in%c("test-Nf","test-train-nf"))|>ggplot(aes(x =vb, y =dist,fill=condit))+stat_summary(geom ="bar", position=position_dodge(), fun =mean)+stat_summary(geom ="errorbar", position=position_dodge(.9), fun.data =mean_se, width =.4, alpha =.7)
# create a kable table to mirror plot of distance effects for vb and condit e1|>filter(expMode%in%c("test-Nf","test-train-nf"))|>group_by(vb,condit)%>%summarise(distMean=mean(dist),distSd=sd(dist))%>%mutate(meanLab=paste0("Mean=",round(distMean,0)),sdLab=paste0("Sd=",round(distSd,0)))%>%mutate(sumStatLab=paste0(meanLab,"\n",sdLab))%>%select(vb,condit,sumStatLab)%>%spread(condit,sumStatLab)%>%kable(format ="html",escape =FALSE)%>%kable_styling(font_size =10)
vb
Constant
Varied
100-300
Mean=254 Sd=298
Mean=386 Sd=426
350-550
Mean=191 Sd=229
Mean=285 Sd=340
600-800
Mean=150 Sd=184
Mean=234 Sd=270
800-1000
Mean=184 Sd=242
Mean=221 Sd=248
1000-1200
Mean=233 Sd=282
Mean=208 Sd=226
1200-1400
Mean=287 Sd=290
Mean=242 Sd=235
e1|>filter(expMode%in%c("test-Nf","test-train-nf"))|>ggplot(aes(x =vb, y =vx,fill=condit))+stat_summary(geom ="bar", position=position_dodge(), fun =mean)+stat_summary(geom ="errorbar", position=position_dodge(.9), fun.data =mean_se, width =.4, alpha =.7)
testAvg|>ggplot(aes(x =vb, y =vx,fill=condit))+stat_summary(geom ="bar", position=position_dodge(), fun =mean)+stat_summary(geom ="errorbar", position=position_dodge(.9), fun.data =mean_se, width =.4, alpha =.7)