-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslides.html
1818 lines (1742 loc) · 109 KB
/
slides.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 lang="en"><head>
<script src="slides_files/libs/clipboard/clipboard.min.js"></script>
<script src="slides_files/libs/quarto-html/tabby.min.js"></script>
<script src="slides_files/libs/quarto-html/popper.min.js"></script>
<script src="slides_files/libs/quarto-html/tippy.umd.min.js"></script>
<link href="slides_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="slides_files/libs/quarto-html/light-border.css" rel="stylesheet">
<link href="slides_files/libs/quarto-html/quarto-syntax-highlighting-d5a2d58599beb33ca06a0ee848de3e43.css" rel="stylesheet" id="quarto-text-highlighting-styles"><meta charset="utf-8">
<meta name="generator" content="quarto-1.6.33">
<meta name="author" content="Dianne Cook Monash University">
<title>Creating effective data plots</title>
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, minimal-ui">
<link rel="stylesheet" href="slides_files/libs/revealjs/dist/reset.css">
<link rel="stylesheet" href="slides_files/libs/revealjs/dist/reveal.css">
<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 -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
vertical-align: middle;
}
/* CSS for syntax highlighting */
pre > code.sourceCode { white-space: pre; position: relative; }
pre > code.sourceCode > span { 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 { display: inline-block; 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>
<link rel="stylesheet" href="slides_files/libs/revealjs/dist/theme/quarto-0eea3bc74b4ef4257017976f653b50d9.css">
<link href="slides_files/libs/revealjs/plugin/quarto-line-highlight/line-highlight.css" rel="stylesheet">
<link href="slides_files/libs/revealjs/plugin/reveal-menu/menu.css" rel="stylesheet">
<link href="slides_files/libs/revealjs/plugin/reveal-menu/quarto-menu.css" rel="stylesheet">
<link href="slides_files/libs/revealjs/plugin/reveal-chalkboard/font-awesome/css/all.css" rel="stylesheet">
<link href="slides_files/libs/revealjs/plugin/reveal-chalkboard/style.css" rel="stylesheet">
<link href="slides_files/libs/revealjs/plugin/quarto-support/footer.css" rel="stylesheet">
<style type="text/css">
.reveal div.sourceCode {
margin: 0;
overflow: auto;
}
.reveal div.hanging-indent {
margin-left: 1em;
text-indent: -1em;
}
.reveal .slide:not(.center) {
height: 100%;
}
.reveal .slide.scrollable {
overflow-y: auto;
}
.reveal .footnotes {
height: 100%;
overflow-y: auto;
}
.reveal .slide .absolute {
position: absolute;
display: block;
}
.reveal .footnotes ol {
counter-reset: ol;
list-style-type: none;
margin-left: 0;
}
.reveal .footnotes ol li:before {
counter-increment: ol;
content: counter(ol) ". ";
}
.reveal .footnotes ol li > p:first-child {
display: inline-block;
}
.reveal .slide ul,
.reveal .slide ol {
margin-bottom: 0.5em;
}
.reveal .slide ul li,
.reveal .slide ol li {
margin-top: 0.4em;
margin-bottom: 0.2em;
}
.reveal .slide ul[role="tablist"] li {
margin-bottom: 0;
}
.reveal .slide ul li > *:first-child,
.reveal .slide ol li > *:first-child {
margin-block-start: 0;
}
.reveal .slide ul li > *:last-child,
.reveal .slide ol li > *:last-child {
margin-block-end: 0;
}
.reveal .slide .columns:nth-child(3) {
margin-block-start: 0.8em;
}
.reveal blockquote {
box-shadow: none;
}
.reveal .tippy-content>* {
margin-top: 0.2em;
margin-bottom: 0.7em;
}
.reveal .tippy-content>*:last-child {
margin-bottom: 0.2em;
}
.reveal .slide > img.stretch.quarto-figure-center,
.reveal .slide > img.r-stretch.quarto-figure-center {
display: block;
margin-left: auto;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-left,
.reveal .slide > img.r-stretch.quarto-figure-left {
display: block;
margin-left: 0;
margin-right: auto;
}
.reveal .slide > img.stretch.quarto-figure-right,
.reveal .slide > img.r-stretch.quarto-figure-right {
display: block;
margin-left: auto;
margin-right: 0;
}
</style>
<link href="slides_files/libs/htmltools-fill-0.5.8.1/fill.css" rel="stylesheet">
<script src="slides_files/libs/htmlwidgets-1.6.4/htmlwidgets.js"></script>
<link href="slides_files/libs/datatables-css-0.0.0/datatables-crosstalk.css" rel="stylesheet">
<script src="slides_files/libs/datatables-binding-0.33/datatables.js"></script>
<script src="slides_files/libs/jquery-3.6.0/jquery-3.6.0.min.js"></script>
<link href="slides_files/libs/dt-core-1.13.6/css/jquery.dataTables.min.css" rel="stylesheet">
<link href="slides_files/libs/dt-core-1.13.6/css/jquery.dataTables.extra.css" rel="stylesheet">
<script src="slides_files/libs/dt-core-1.13.6/js/jquery.dataTables.min.js"></script>
<link href="slides_files/libs/crosstalk-1.2.1/css/crosstalk.min.css" rel="stylesheet">
<script src="slides_files/libs/crosstalk-1.2.1/js/crosstalk.min.js"></script>
<link href="slides_files/libs/countdown-0.4.0/countdown.css" rel="stylesheet">
<script src="slides_files/libs/countdown-0.4.0/countdown.js"></script>
</head>
<body class="quarto-light">
<div class="reveal">
<div class="slides">
<section id="title-slide" class="quarto-title-block center">
<h1 class="title">Creating effective data plots</h1>
<div class="quarto-title-authors">
<div class="quarto-title-author">
<div class="quarto-title-author-name">
Dianne Cook <br> Monash University
</div>
</div>
</div>
</section>
<section id="why-13" class="slide level2">
<h2>Why <span class="f50">(1/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/mtcars-resid-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="Plot of residuals against fitted values shows a slight non-linear pattern. Two outliers, high residual but low fitted value affect the reading of the nonlinear pattern."></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:50%;">
<p>Is there any pattern in the residuals that indicate a problem with the model fit?</p>
<p><br></p>
<div class="f90">
<p>Do we need to change the model specification?</p>
</div>
</div></div>
</section>
<section id="why-23" class="slide level2">
<h2>Why <span class="f50">(2/3)</span></h2>
<img data-src="slides_files/figure-revealjs/wasps-1.png" class="quarto-figure quarto-figure-center r-stretch" style="width:100.0%" alt="Scatterplot of first two linear discriminants, with points coloured by wasp species, F, G, Q, W. F and G are well-separated clusters but Q and W are adjoining."><center>
<p><br> Is there a difference between the species?</p>
</center>
</section>
<section id="why-33" class="slide level2">
<h2>Why <span class="f50">(3/3)</span></h2>
<center>
<p><br> Which is the best display to answer: what is distribution of thyroid cancer across Australia?</p>
</center>
<div class="columns">
<div class="column">
<p><img data-src="images/thyroid-choro-1.png" alt="Choropleth map of thyroid cancer across Australian LGAs. High incidence appears to be around Brisbane and west of Sydney city."></p>
</div><div class="column">
<p><img data-src="images/thyroid-hex-1.png" alt="Hexagon tile map of thyroid cancer across Australian LGAs. High incidence is seen across the Brisbane, Sydney and Perth areas. Some LGAs in Melbourne have higher values too."></p>
</div></div>
</section>
<section id="whats-the-goal" class="slide level2">
<h2>What’s the goal?</h2>
<p><br></p>
<p>Reading data plots is <span style="color: #F5191C;">subjective</span>.</p>
<div class="fragment">
<p><br> Making decisions based on data visualisations is common, where <span style="color: #3B99B1;"> we need to be objective </span>.</p>
</div>
<div class="fragment" style="margin-left:230px">
<p><br><br><br> It is possible, and <span style="color: #3B99B1;"> here is how we do that …</span></p>
</div>
</section>
<section id="outline" class="slide level2">
<h2>Outline</h2>
<ul>
<li>Organising your data into tidy form</li>
<li>Mapping the variables to elements of the plot</li>
<li>Cognitive principles: briefly</li>
<li>Testing the strength of patterns in the plot</li>
<li>Testing which is the best design</li>
</ul>
</section>
<section id="these-are-the-tools-you-need" class="slide level2">
<h2>These are the tools you need</h2>
<div class="{.columns]">
<div class="column" style="width:45%;">
<div class="textbox">
<p><img data-src="https://ggplot2.tidyverse.org/logo.png" width="150"></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb1"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb1-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"ggplot2"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="f60">
<p>or better yet:</p>
</div>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb2"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb2-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"tidyverse"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="f60">
<ul>
<li>Define your plots using a grammar that maps variables in tidy data to elements of the plot.</li>
<li>Wrangle your data into tidy form for clarity of plot specification.</li>
</ul>
</div>
</div>
</div><div class="column" style="width:8%;">
<p><span style="color: #FFFFFF;"> space </span></p>
</div><div class="column" style="width:45%;">
<div class="textbox">
<p><img data-src="https://dicook.github.io/nullabor/reference/figures/nullabor_hex.png" width="170"></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb3"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb3-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">install.packages</span>(<span class="st">"nullabor"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="f60">
<ul>
<li>Compare your data plot to plots of null data.</li>
<li>This checks whether what we see is real or spurious.</li>
<li>Also allows for measuring the effectiveness of one plot design vs another.</li>
</ul>
</div>
</div>
</div></div>
</section>
<section id="organising-your-data-to-enable-mapping-variables-to-graphical-elements" class="slide level2 transition center">
<h2>Organising your data to enable mapping variables to graphical elements</h2>
</section>
<section id="tidy-data" class="slide level2">
<h2>Tidy data</h2>
<p><img data-src="https://cdn.myportfolio.com/45214904-6a61-4e23-98d6-b140f8654a40/6e297111-efb7-4555-93d2-085071d1853c_rw_1920.jpg?h=f1951b118eaddaaab8a572422bc16566" class="absolute" style="top: 0px; right: 0px; width: 550px; "></p>
<p><br><br><br><br></p>
<ol type="1">
<li><strong>Each variable forms a column</strong></li>
<li><strong>Each observation forms a row</strong></li>
<li><strong>Each type of observational unit forms a table.</strong> If you have data on multiple levels (e.g. data about houses and data about the rooms within those houses), these should be in separate tables.</li>
</ol>
<div style="font-size: 40%;">
<p>Illustrations from the Openscapes blog Tidy Data for reproducibility, efficiency, and collaboration by <a href="https://allisonhorst.com/other-r-fun">Julia Lowndes and Allison Horst</a></p>
</div>
</section>
<section id="question" class="slide level2 transition center">
<h2>QUESTION</h2>
<p>How would you get this data into tidy form?</p>
</section>
<section id="tuberculosis-from-who" class="slide level2">
<h2>Tuberculosis from WHO</h2>
<div class="f50">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="datatables html-widget html-fill-item" id="htmlwidget-88ec3c06f8e20f3dd37e" style="width:100%;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-88ec3c06f8e20f3dd37e">{"x":{"filter":"none","vertical":false,"data":[["1","2","3","4","5","6","7","8","9","10","11"],["AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS"],[1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007],[1,0,0,3,1,1,0,0,0,1,3],[8,11,13,16,23,15,14,18,32,33,30],[24,22,40,35,20,20,10,16,27,35,33],[18,18,54,25,18,26,2,17,23,23,20],[13,13,52,24,18,19,11,15,11,21,15],[17,15,37,19,13,13,5,11,12,16,14],[28,31,49,49,35,34,30,32,30,43,37],[0,2,0,0,1,0,0,0,2,2,4],[10,19,10,15,21,15,9,6,18,18,26],[15,24,16,19,27,21,13,17,26,27,37],[9,15,18,12,16,15,3,5,11,14,20],[5,8,6,15,7,6,5,7,10,7,12],[10,2,2,5,8,4,4,3,6,9,7],[12,24,26,14,20,23,7,19,14,21,23]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th> <\/th>\n <th>iso3<\/th>\n <th>year<\/th>\n <th>new_sp_m014<\/th>\n <th>new_sp_m1524<\/th>\n <th>new_sp_m2534<\/th>\n <th>new_sp_m3544<\/th>\n <th>new_sp_m4554<\/th>\n <th>new_sp_m5564<\/th>\n <th>new_sp_m65<\/th>\n <th>new_sp_f014<\/th>\n <th>new_sp_f1524<\/th>\n <th>new_sp_f2534<\/th>\n <th>new_sp_f3544<\/th>\n <th>new_sp_f4554<\/th>\n <th>new_sp_f5564<\/th>\n <th>new_sp_f65<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"dom":"t","columnDefs":[{"className":"dt-right","targets":[2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]},{"orderable":false,"targets":0},{"name":" ","targets":0},{"name":"iso3","targets":1},{"name":"year","targets":2},{"name":"new_sp_m014","targets":3},{"name":"new_sp_m1524","targets":4},{"name":"new_sp_m2534","targets":5},{"name":"new_sp_m3544","targets":6},{"name":"new_sp_m4554","targets":7},{"name":"new_sp_m5564","targets":8},{"name":"new_sp_m65","targets":9},{"name":"new_sp_f014","targets":10},{"name":"new_sp_f1524","targets":11},{"name":"new_sp_f2534","targets":12},{"name":"new_sp_f3544","targets":13},{"name":"new_sp_f4554","targets":14},{"name":"new_sp_f5564","targets":15},{"name":"new_sp_f65","targets":16}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
</div>
</section>
<section id="tidying" class="slide level2">
<h2>Tidying</h2>
<div class="columns">
<div class="column" style="width:49%;">
<p>First get the data in tidy form</p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb4" data-code-line-numbers="3,6,10,12"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb4-1"><a href=""></a>tb_aus_sa <span class="ot"><-</span> tb_aus <span class="sc">|></span></span>
<span id="cb4-2"><a href=""></a> <span class="fu">filter</span>(year <span class="sc">></span> <span class="dv">2012</span>) <span class="sc">|></span></span>
<span id="cb4-3"><a href=""></a> <span class="fu">select</span>(iso3, year, </span>
<span id="cb4-4"><a href=""></a> newrel_f014<span class="sc">:</span>newrel_f65, </span>
<span id="cb4-5"><a href=""></a> newrel_m014<span class="sc">:</span>newrel_m65) <span class="sc">|></span></span>
<span id="cb4-6"><a href=""></a> <span class="fu">pivot_longer</span>(<span class="at">cols=</span>newrel_f014<span class="sc">:</span>newrel_m65,</span>
<span id="cb4-7"><a href=""></a> <span class="at">names_to =</span> <span class="st">"sex_age"</span>, </span>
<span id="cb4-8"><a href=""></a> <span class="at">values_to =</span> <span class="st">"count"</span>) <span class="sc">|></span></span>
<span id="cb4-9"><a href=""></a> <span class="fu">filter</span>(<span class="sc">!</span><span class="fu">is.na</span>(count)) <span class="sc">|></span></span>
<span id="cb4-10"><a href=""></a> <span class="fu">separate</span>(sex_age, <span class="at">into=</span><span class="fu">c</span>(<span class="st">"stuff"</span>, </span>
<span id="cb4-11"><a href=""></a> <span class="st">"sex_age"</span>)) <span class="sc">|></span></span>
<span id="cb4-12"><a href=""></a> <span class="fu">mutate</span>(<span class="at">sex =</span> <span class="fu">str_sub</span>(sex_age, <span class="dv">1</span>, <span class="dv">1</span>),</span>
<span id="cb4-13"><a href=""></a> <span class="at">age =</span> <span class="fu">str_sub</span>(sex_age, <span class="dv">2</span>, </span>
<span id="cb4-14"><a href=""></a> <span class="fu">str_length</span>(sex_age))) <span class="sc">|></span></span>
<span id="cb4-15"><a href=""></a> <span class="fu">mutate</span>(<span class="at">age =</span> <span class="fu">case_when</span>(</span>
<span id="cb4-16"><a href=""></a> age <span class="sc">==</span> <span class="st">"014"</span> <span class="sc">~</span> <span class="st">"0-14"</span>,</span>
<span id="cb4-17"><a href=""></a> age <span class="sc">==</span> <span class="st">"1524"</span> <span class="sc">~</span> <span class="st">"15-24"</span>,</span>
<span id="cb4-18"><a href=""></a> age <span class="sc">==</span> <span class="st">"2534"</span> <span class="sc">~</span> <span class="st">"25-34"</span>,</span>
<span id="cb4-19"><a href=""></a> age <span class="sc">==</span> <span class="st">"3544"</span> <span class="sc">~</span> <span class="st">"35-44"</span>,</span>
<span id="cb4-20"><a href=""></a> age <span class="sc">==</span> <span class="st">"4554"</span> <span class="sc">~</span> <span class="st">"45-54"</span>,</span>
<span id="cb4-21"><a href=""></a> age <span class="sc">==</span> <span class="st">"5564"</span> <span class="sc">~</span> <span class="st">"55-64"</span>,</span>
<span id="cb4-22"><a href=""></a> age <span class="sc">==</span> <span class="st">"65"</span> <span class="sc">~</span> <span class="st">"65"</span>)) <span class="sc">|></span></span>
<span id="cb4-23"><a href=""></a> <span class="fu">select</span>(iso3, year, sex, age, count)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div><div class="column" style="width:49%;">
<div class="fragment">
<div class="f50">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="datatables html-widget html-fill-item" id="htmlwidget-4fde62bb84ca66e8fbc0" style="width:100%;height:auto;"></div>
<script type="application/json" data-for="htmlwidget-4fde62bb84ca66e8fbc0">{"x":{"filter":"none","vertical":false,"data":[["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"],["AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS","AUS"],[2013,2013,2013,2013,2013,2013,2013,2013,2013,2013,2013,2013,2013,2013,2014,2014,2014,2014,2014,2014,2014,2014,2014,2014,2014,2014,2014,2014,2015,2015,2015,2015,2015,2015,2015,2015,2015,2015,2015,2015,2015,2015,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2016,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2017,2018,2018,2018,2018,2018,2018,2018,2018,2018,2018,2018,2018,2018,2018,2019,2019,2019,2019,2019,2019,2019,2019,2019,2019,2019,2019,2019,2019,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2020,2021,2021,2021,2021,2021,2021,2021,2021,2021,2021,2021,2021,2021,2021],["f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m","f","f","f","f","f","f","f","m","m","m","m","m","m","m"],["0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65","0-14","15-24","25-34","35-44","45-54","55-64","65"],[20,95,165,97,62,46,63,28,105,206,108,67,68,120,25,86,206,114,70,45,77,28,102,167,100,73,90,147,24,87,195,108,60,51,73,22,96,165,92,66,87,128,16,98,218,108,58,60,81,22,92,181,125,68,92,157,32,118,203,110,63,63,82,25,110,190,123,73,87,163,30,115,216,103,79,65,89,19,107,169,132,71,93,150,22,111,218,105,84,77,90,21,151,210,109,57,79,168,18,141,238,124,85,62,90,15,150,221,135,69,92,171,18,97,199,129,67,74,92,16,114,202,121,89,83,156]],"container":"<table class=\"display\">\n <thead>\n <tr>\n <th> <\/th>\n <th>iso3<\/th>\n <th>year<\/th>\n <th>sex<\/th>\n <th>age<\/th>\n <th>count<\/th>\n <\/tr>\n <\/thead>\n<\/table>","options":{"dom":"t","columnDefs":[{"className":"dt-right","targets":[2,5]},{"orderable":false,"targets":0},{"name":" ","targets":0},{"name":"iso3","targets":1},{"name":"year","targets":2},{"name":"sex","targets":3},{"name":"age","targets":4},{"name":"count","targets":5}],"order":[],"autoWidth":false,"orderClasses":false}},"evals":[],"jsHooks":[]}</script>
</div>
</div>
</div>
</div>
</div></div>
</section>
<section id="statistical-data" class="slide level2">
<h2>Statistical data</h2>
<p><span class="math display">\[X = \left[ \begin{array}{rrrr}
X_{~1} & X_{~2} & ... & X_{~p}
\end{array} \right] \\
= \left[ \begin{array}{rrrr}
X_{~11} & X_{~12} & ... & X_{~1p} \\
X_{~21} & X_{~22} & ... & X_{~2p} \\
\vdots & \vdots & \ddots& \vdots \\
X_{~n1} & X_{~n2} & ... & X_{~np}
\end{array} \right]\]</span></p>
<ul>
<li><span style="color: #3B99B1;">This is tidy data!</span></li>
<li>You might also make assumptions about the distribution of each variable, e.g. <span class="math inline">\(X_{~1} \sim N(0,1), ~~X_{~2} \sim \text{Exp}(1) ...\)</span></li>
</ul>
</section>
<section id="mapping" class="slide level2">
<h2>Mapping</h2>
<p>In <code>ggplot2</code>, the variables from tidy data are explicitly mapped to elements of the plot, using <code>aesthetics</code>.</p>
<div class="columns">
<div class="column" style="width:49%;">
<div class="f50">
<p><strong>Basic Mappings</strong></p>
<ul>
<li><code>x</code> and <code>y</code> to plot points in a two-dimensional space</li>
<li><code>color</code>, <code>fill</code> to render as a color scale</li>
<li><code>size</code> maps variable to size of object</li>
<li><code>shape</code> maps variable to different shapes</li>
</ul>
<p>Depending on the <code>geom</code> different mappings are possible, <code>xmin</code>, <code>xend</code>, <code>linetype</code>, <code>alpha</code>, <code>stroke</code>, <code>weight</code> …</p>
<p><strong>Facets</strong></p>
<p>Variables are used to subset (or condition)</p>
<p><strong>Layers</strong></p>
<p>Different data can be mapped onto the same plot, eg observations, and means</p>
</div>
</div><div class="column" style="width:49%;">
<div class="fragment">
<p><strong>Example</strong></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb5"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb5-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(mpg, </span>
<span id="cb5-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(</span>
<span id="cb5-3"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">x=</span>displ, </span>
<span id="cb5-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>hwy, </span>
<span id="cb5-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">color=</span>class)) <span class="sc">+</span> </span>
<span id="cb5-6"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<div class="f60">
<p><code>displ</code> is mapped to <code>x</code><br> <code>hwy</code> is mapped to <code>y</code><br> <code>class</code> is mapped to <code>color</code>.</p>
</div>
</div>
</div></div>
</section>
<section id="common-plot-descriptions-as-scripts" class="slide level2 transition center">
<h2>Common plot descriptions as scripts</h2>
</section>
<section id="example-1a" class="slide level2">
<h2>Example 1A</h2>
<div class="columns">
<div class="column" style="width:49%;">
<p>How are variables mapped to create this plot?</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/aus-tb-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="Scatterplot of TB incidence (ranging from 900-1600) against years 1997-2021. It has 2 layers. Layer 1 is a set of 25 big solid circle points of which about 100% can be seen. Layer 2 is a lowess smoothed curve. Layer 2 has colour set to vivid red. There is a roughly linearly increasing pattern. "></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:49%;">
<p><br><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb6" data-code-line-numbers="2,3,4"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb6-1"><a href=""></a><span class="fu">ggplot</span>(tb_aus, </span>
<span id="cb6-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>year, </span>
<span id="cb6-3"><a href=""></a> <span class="at">y=</span>c_newinc)) <span class="sc">+</span> </span>
<span id="cb6-4"><a href=""></a> <span class="fu">geom_point</span>() <span class="sc">+</span></span>
<span id="cb6-5"><a href=""></a> <span class="fu">scale_x_continuous</span>(<span class="st">"Year"</span>, </span>
<span id="cb6-6"><a href=""></a> <span class="at">breaks =</span> <span class="fu">seq</span>(<span class="dv">1980</span>, <span class="dv">2020</span>, <span class="dv">10</span>), </span>
<span id="cb6-7"><a href=""></a> <span class="at">labels =</span> <span class="fu">c</span>(<span class="st">"80"</span>, <span class="st">"90"</span>, <span class="st">"00"</span>, <span class="st">"10"</span>, <span class="st">"20"</span>)) <span class="sc">+</span></span>
<span id="cb6-8"><a href=""></a> <span class="fu">ylab</span>(<span class="st">"TB incidence"</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div></div>
</section>
<section id="example-1b" class="slide level2">
<h2>Example 1B</h2>
<div class="columns">
<div class="column" style="width:49%;">
<p>How are variables mapped to create this plot?</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/aus-tb-bar-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="Scatterplot of TB incidence (ranging from 900-1600) against years 1997-2021. It has 2 layers. Layer 1 is a set of 25 big solid circle points of which about 100% can be seen. Layer 2 is a lowess smoothed curve. Layer 2 has colour set to vivid red. There is a roughly linearly increasing pattern. "></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:49%;">
<p><br><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb7" data-code-line-numbers="2,3,4,5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb7-1"><a href=""></a><span class="fu">ggplot</span>(tb_aus, </span>
<span id="cb7-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>year, </span>
<span id="cb7-3"><a href=""></a> <span class="at">y=</span>c_newinc)) <span class="sc">+</span> </span>
<span id="cb7-4"><a href=""></a> <span class="fu">geom_point</span>() <span class="sc">+</span></span>
<span id="cb7-5"><a href=""></a> <span class="fu">geom_smooth</span>(<span class="at">se=</span>F, <span class="at">colour=</span><span class="st">"#F5191C"</span>) <span class="sc">+</span></span>
<span id="cb7-6"><a href=""></a> <span class="fu">scale_x_continuous</span>(<span class="st">"Year"</span>, <span class="at">breaks =</span> <span class="fu">seq</span>(<span class="dv">1980</span>, <span class="dv">2020</span>, <span class="dv">10</span>), <span class="at">labels =</span> <span class="fu">c</span>(<span class="st">"80"</span>, <span class="st">"90"</span>, <span class="st">"00"</span>, <span class="st">"10"</span>, <span class="st">"20"</span>)) <span class="sc">+</span></span>
<span id="cb7-7"><a href=""></a> <span class="fu">ylab</span>(<span class="st">"TB incidence"</span>) </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div></div>
</section>
<section id="example-2a" class="slide level2">
<h2>Example 2A</h2>
<div class="columns">
<div class="column" style="width:49%;">
<p>How are variables mapped to create this plot?</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/penguins1-1.png" class="quarto-figure quarto-figure-center" style="width:80.0%" alt="This is an untitled chart with no subtitle or caption. It has x-axis flipper_length_mm with labels 170, 180, 190, 200, 210, 220 and 230. It has y-axis bill_length_mm with labels 40, 50 and 60. There is a legend indicating colour is used to show species, with 3 levels: Adelie shown as brilliant greenish blue colour, Chinstrap shown as brilliant yellow colour and Gentoo shown as vivid red colour. The chart is a set of 342 big solid circle points of which about 92% can be seen. It has alpha set to 0.8. The three species form clusters, but they are not separated. Adelie is at low left, Gentoo is upper right, and Chinstrap is middle and mid-to-upper positions. "></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:49%;">
<p><br><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb8" data-code-line-numbers="2,3,4,5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb8-1"><a href=""></a><span class="fu">ggplot</span>(penguins, </span>
<span id="cb8-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>flipper_length_mm, </span>
<span id="cb8-3"><a href=""></a> <span class="at">y=</span>bill_length_mm, </span>
<span id="cb8-4"><a href=""></a> <span class="at">color=</span>species)) <span class="sc">+</span> </span>
<span id="cb8-5"><a href=""></a> <span class="fu">geom_point</span>(<span class="at">alpha=</span><span class="fl">0.8</span>) <span class="sc">+</span></span>
<span id="cb8-6"><a href=""></a> <span class="fu">scale_color_discrete_divergingx</span>(<span class="at">palette=</span><span class="st">"Zissou 1"</span>) <span class="sc">+</span></span>
<span id="cb8-7"><a href=""></a> <span class="fu">theme</span>(<span class="at">legend.title =</span> <span class="fu">element_blank</span>(), </span>
<span id="cb8-8"><a href=""></a> <span class="at">legend.position =</span> <span class="st">"bottom"</span>,</span>
<span id="cb8-9"><a href=""></a> <span class="at">legend.direction =</span> <span class="st">"horizontal"</span>,</span>
<span id="cb8-10"><a href=""></a> <span class="at">legend.text =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="st">"8"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div></div>
</section>
<section id="example-2b" class="slide level2">
<h2>Example 2B</h2>
<div class="columns">
<div class="column" style="width:49%;">
<p>How are variables mapped to create this plot?</p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/penguins2-1.png" class="quarto-figure quarto-figure-center" style="width:80.0%" alt="Density plots of flipper length ranging from 170-230 and bill length ranging from 30-60. Points are coloured by species. The three species form clusters, but they are not separated. Adelie is at low left, Gentoo is upper right, and Chinstrap is middle and mid-to-upper positions. "></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:49%;">
<p><br><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb9" data-code-line-numbers="2,3,4,5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb9-1"><a href=""></a><span class="fu">ggplot</span>(penguins, </span>
<span id="cb9-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>flipper_length_mm, </span>
<span id="cb9-3"><a href=""></a> <span class="at">y=</span>bill_length_mm, </span>
<span id="cb9-4"><a href=""></a> <span class="at">color=</span>species)) <span class="sc">+</span> </span>
<span id="cb9-5"><a href=""></a> <span class="fu">geom_density2d</span>(<span class="at">alpha=</span><span class="fl">0.8</span>) <span class="sc">+</span></span>
<span id="cb9-6"><a href=""></a> <span class="fu">scale_color_discrete_divergingx</span>(<span class="at">palette=</span><span class="st">"Zissou 1"</span>) <span class="sc">+</span></span>
<span id="cb9-7"><a href=""></a> <span class="fu">theme</span>(<span class="at">legend.title =</span> <span class="fu">element_blank</span>(), </span>
<span id="cb9-8"><a href=""></a> <span class="at">legend.position =</span> <span class="st">"bottom"</span>,</span>
<span id="cb9-9"><a href=""></a> <span class="at">legend.direction =</span> <span class="st">"horizontal"</span>,</span>
<span id="cb9-10"><a href=""></a> <span class="at">legend.text =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="st">"8"</span>))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</div></div>
</section>
<section id="easily-re-plot-different-ways-12" class="slide level2">
<h2>Easily re-plot different ways <span class="f50">(1/2)</span></h2>
<div style="font-size: 80%;">
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb10" data-code-line-numbers="2,3,4,5"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb10-1"><a href=""></a><span class="fu">ggplot</span>(tb_aus_sa, </span>
<span id="cb10-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>year, </span>
<span id="cb10-3"><a href=""></a> <span class="at">y=</span>count, </span>
<span id="cb10-4"><a href=""></a> <span class="at">fill=</span>sex)) <span class="sc">+</span> </span>
<span id="cb10-5"><a href=""></a> <span class="fu">geom_col</span>(<span class="at">position=</span><span class="st">"fill"</span>) <span class="sc">+</span></span>
<span id="cb10-6"><a href=""></a> <span class="fu">facet_wrap</span>(<span class="sc">~</span>age, <span class="at">ncol=</span><span class="dv">7</span>) <span class="sc">+</span></span>
<span id="cb10-7"><a href=""></a> <span class="fu">ylab</span>(<span class="st">""</span>) <span class="sc">+</span></span>
<span id="cb10-8"><a href=""></a> <span class="fu">scale_fill_discrete_divergingx</span>(<span class="at">palette=</span><span class="st">"ArmyRose"</span>) <span class="sc">+</span></span>
<span id="cb10-9"><a href=""></a> <span class="fu">scale_x_continuous</span>(<span class="st">"year"</span>, </span>
<span id="cb10-10"><a href=""></a> <span class="at">breaks =</span> <span class="fu">seq</span>(<span class="dv">2013</span>, <span class="dv">2021</span>, <span class="dv">2</span>), </span>
<span id="cb10-11"><a href=""></a> <span class="at">labels =</span> <span class="fu">c</span>(<span class="st">"13"</span>, <span class="st">"15"</span>, <span class="st">"17"</span>, <span class="st">"19"</span>, <span class="st">"21"</span>)) <span class="sc">+</span></span>
<span id="cb10-12"><a href=""></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"bottom"</span>, </span>
<span id="cb10-13"><a href=""></a> <span class="at">legend.direction =</span> <span class="st">"horizontal"</span>,</span>
<span id="cb10-14"><a href=""></a> <span class="at">legend.title =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb10-15"><a href=""></a> <span class="at">axis.text =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="st">"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 class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-21-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="This is an untitled chart with no subtitle or caption. The chart is comprised of 7 panels containing sub-charts, arranged horizontally. The panels represent different values of age. Each sub-chart has x-axis 'year' with labels 13, 15, 17, 19 and 21. Each sub-chart has y-axis with labels 0.00, 0.25, 0.50, 0.75 and 1.00. There is a legend indicating fill is used to show sex, with 2 levels: females shown as deep pink fill and males shown as light olive fill."></p>
</figure>
</div>
</div>
</div>
</div>
<div class="fragment f60">
<p><br> Observations: Relatively equal proportions, with more incidence among males in older population. No clear temporal trend.</p>
</div>
</section>
<section id="easily-re-plot-different-ways-22" class="slide level2">
<h2>Easily re-plot different ways <span class="f50">(2/2)</span></h2>
<div style="font-size: 80%;">
<div class="cell" data-layout-align="center">
<details class="code-fold">
<summary>Code</summary>
<div class="sourceCode cell-code" id="cb11" data-code-line-numbers="2,3,4,5,6"><pre class="sourceCode numberSource r number-lines code-with-copy"><code class="sourceCode r"><span id="cb11-1"><a href=""></a><span class="fu">ggplot</span>(tb_aus_sa, </span>
<span id="cb11-2"><a href=""></a> <span class="fu">aes</span>(<span class="at">x=</span>year, </span>
<span id="cb11-3"><a href=""></a> <span class="at">y=</span>count, </span>
<span id="cb11-4"><a href=""></a> <span class="at">colour=</span>sex)) <span class="sc">+</span> </span>
<span id="cb11-5"><a href=""></a> <span class="fu">geom_point</span>() <span class="sc">+</span></span>
<span id="cb11-6"><a href=""></a> <span class="fu">geom_smooth</span>(<span class="at">se=</span>F, <span class="at">alpha=</span><span class="fl">0.7</span>) <span class="sc">+</span></span>
<span id="cb11-7"><a href=""></a> <span class="fu">facet_grid</span>(sex<span class="sc">~</span>age, <span class="at">scales =</span> <span class="st">"free_y"</span>) <span class="sc">+</span></span>
<span id="cb11-8"><a href=""></a> <span class="fu">ylab</span>(<span class="st">"count"</span>) <span class="sc">+</span></span>
<span id="cb11-9"><a href=""></a> <span class="fu">scale_colour_discrete_divergingx</span>(<span class="at">palette=</span><span class="st">"ArmyRose"</span>) <span class="sc">+</span></span>
<span id="cb11-10"><a href=""></a> <span class="fu">scale_x_continuous</span>(<span class="st">"year"</span>, </span>
<span id="cb11-11"><a href=""></a> <span class="at">breaks =</span> <span class="fu">seq</span>(<span class="dv">2013</span>, <span class="dv">2021</span>, <span class="dv">2</span>), </span>
<span id="cb11-12"><a href=""></a> <span class="at">labels =</span> <span class="fu">c</span>(<span class="st">"13"</span>, <span class="st">"15"</span>, <span class="st">"17"</span>, <span class="st">"19"</span>, <span class="st">"21"</span>)) <span class="sc">+</span></span>
<span id="cb11-13"><a href=""></a> <span class="fu">theme</span>(<span class="at">legend.position =</span> <span class="st">"bottom"</span>, </span>
<span id="cb11-14"><a href=""></a> <span class="at">legend.direction =</span> <span class="st">"horizontal"</span>,</span>
<span id="cb11-15"><a href=""></a> <span class="at">legend.title =</span> <span class="fu">element_blank</span>(),</span>
<span id="cb11-16"><a href=""></a> <span class="at">axis.text =</span> <span class="fu">element_text</span>(<span class="at">size=</span><span class="st">"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 class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-22-1.png" class="quarto-figure quarto-figure-center" style="width:80.0%" alt="The chart is comprised of 14 panels containing sub-charts, arranged in a grid. The panel rows represent different values of sex. The panel columns represent different values of age. There is a legend indicating colour is used to show sex, with 2 levels: females shown as deep pink colour and males shown as light olive colour. Each sub-chart has 2 layers. Layer 1 of is a set of 9 big solid circle points, and layer 2 is a lowess smoothed curve."></p>
</figure>
</div>
</div>
</div>
</div>
<div class="fragment f60">
<p><br> Small increasing temporal trend is present in early age groups, for both males and females. Also older groups, although numbers are much smaller.</p>
</div>
</section>
<section id="tidy-data-to-plot-descriptions-allows-quick-re-arrangment-and-clearly-shows-relationship-between-plots" class="slide level2 center">
<h2>Tidy data to plot descriptions allows quick re-arrangment, and clearly shows relationship between plots</h2>
</section>
<section id="cognitive-principles" class="slide level2 transition center">
<h2>Cognitive principles</h2>
</section>
<section id="hierarchy-of-mappings" class="slide level2">
<h2>Hierarchy of mappings</h2>
<p><img src="images/task-position-common-scale-1.svg" width="200px"><img src="images/task-position-non-aligned-scale-1.svg" width="200px" style="padding-left:10px;"><img src="images/task-length-1.svg" width="200px" style="padding-left:10px;"><img src="images/task-direction-1.svg" width="200px" style="padding-left:10px;"><img src="images/task-angle-1.svg" width="200px" style="padding-left:10px;"></p>
<p><img src="images/task-area-1.svg" width="200px"><img src="images/task-volume-1.svg" width="200px" style="padding-left:10px;"><img src="images/task-curvature-1.svg" width="200px" style="padding-left:10px;"><img src="images/task-texture.svg" style="padding-left:10px;" width="200px"><img src="images/task-shape-1.svg" width="200px" style="padding-left:10px;"></p>
<p>Cleveland and McGill (1984)</p>
<div class="f50">
<center>
<br><br>Illustrations made by Emi Tanaka
</center>
</div>
</section>
<section id="hierarchy-of-mappings-1" class="slide level2">
<h2>Hierarchy of mappings</h2>
<div class="columns">
<div class="column" style="width:50%;">
<ol type="1">
<li>Position - common scale (BEST)</li>
<li>Position - nonaligned scale</li>
<li>Length, direction, angle</li>
<li>Area</li>
<li>Volume, curvature</li>
<li>Shading, color (WORST)</li>
</ol>
</div><div class="column fragment" style="width:50%;">
<ol type="1">
<li>scatterplot, barchart</li>
<li>side-by-side boxplot, stacked barchart</li>
<li>piechart, rose plot, gauge plot, donut, wind direction map, starplot</li>
<li>treemap, bubble chart, mosaicplot</li>
<li>chernoff face</li>
<li>choropleth map</li>
</ol>
</div></div>
</section>
<section id="proximity" class="slide level2">
<h2>Proximity</h2>
<p>Place elements that you want to compare close to each other. If there are multiple comparisons to make, you need to decide which one is most important.</p>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-24-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-25-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
</div></div>
</section>
<section id="change-blindness" class="slide level2">
<h2>Change blindness</h2>
<p>Making comparisons across plots requires the eye to jump from one focal point to another. It may result in not noticing differences.</p>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-26-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
</div><div class="column fragment center" style="width:50%;">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-27-1.png" class="quarto-figure quarto-figure-center" style="width:60.0%"></p>
</figure>
</div>
</div>
</div>
</div></div>
</section>
<section id="scaling" class="slide level2">
<h2>Scaling</h2>
<p>For comparison of different patterns, consider the scale. Typically the scale should be the SAME in each plot.</p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb12"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb12-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">facet_wrap</span>(..., <span class="at">scales=</span><span class="st">"free_y"</span>)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
</section>
<section id="statistical-thinking" class="slide level2 transition center">
<h2>Statistical thinking</h2>
</section>
<section id="statistical-thinking-1" class="slide level2">
<h2>Statistical thinking</h2>
<ul>
<li>Because the <span style="color: #3B99B1;"> plot </span> is specified using a functional mapping of the variables, it <span style="color: #3B99B1;"> is a statistic</span>.</li>
<li>The null and alternative hypotheses are indicated from the plot description.</li>
<li>Applying the function to a dataset provides the observed value.</li>
</ul>
</section>
<section id="what-is-your-plot-testing-13" class="slide level2">
<h2>What is your plot testing? <span class="f50">(1/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb13"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb13-1"><a href="" aria-hidden="true" tabindex="-1"></a>LM_FIT <span class="ot"><-</span> <span class="fu">lm</span>(VAR2 <span class="sc">~</span> VAR1, </span>
<span id="cb13-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> DATA)</span>
<span id="cb13-3"><a href="" aria-hidden="true" tabindex="-1"></a>FIT_ALL <span class="ot"><-</span> <span class="fu">augment</span>(LM_FIT)</span>
<span id="cb13-4"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(FIT_ALL, <span class="fu">aes</span>(<span class="at">x=</span>.FITTED, </span>
<span id="cb13-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>.RESID)) <span class="sc">+</span> </span>
<span id="cb13-6"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br> What will we be assessing using this plot?</p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:40%;">
<div class="fragment">
<p>Is the model misspecified?</p>
<div class="f90">
<ul>
<li>non-linearity</li>
<li>heteroskedasticity</li>
<li>outliers/anomalies</li>
<li>non-normality</li>
<li>fitted value distribution</li>
</ul>
</div>
</div>
</div></div>
</section>
<section id="what-is-your-plot-testing-13-1" class="slide level2">
<h2>What is your plot testing? <span class="f50">(1/3)</span></h2>
<div class="columns">
<div class="column" style="width:60%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-30-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="Plot of residuals against fitted values shows a slight non-linear pattern. Two outliers, high residual but low fitted value affect the reading of the nonlinear pattern."></p>
</figure>
</div>
</div>
</div>
</div><div class="column" style="width:40%;">
<p>What do you see?</p>
<div class="fragment">
<p>✗ non-linearity <br> ✓ heteroskedasticity <br> ✗ outliers/anomalies <br> ✓ non-normality <br> ✗ fitted value distribution is uniform</p>
</div>
<div class="fragment">
<p><br> <span style="color: #F5191C;"> Are you sure? </span></p>
</div>
</div></div>
</section>
<section id="what-is-your-plot-testing-23" class="slide level2">
<h2>What is your plot testing? <span class="f50">(2/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb14"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb14-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(DATA, </span>
<span id="cb14-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>VAR1, </span>
<span id="cb14-3"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>VAR2, </span>
<span id="cb14-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">color=</span>CLASS)) <span class="sc">+</span> </span>
<span id="cb14-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>() </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br> What will we be assessing using this plot?</p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:40%;">
<div class="fragment">
<p><br> Is there a difference between the groups?</p>
<ul>
<li>location</li>
<li>shape</li>
<li>outliers/anomalies</li>
</ul>
</div>
</div></div>
</section>
<section id="what-is-your-plot-testing-23-1" class="slide level2">
<h2>What is your plot testing? <span class="f50">(2/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-32-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%" alt="This is an untitled chart with no subtitle or caption. It has x-axis flipper_length_mm with labels 170, 180, 190, 200, 210, 220 and 230. It has y-axis bill_length_mm with labels 40, 50 and 60. There is a legend indicating colour is used to show species, with 3 levels: Adelie shown as brilliant greenish blue colour, Chinstrap shown as brilliant yellow colour and Gentoo shown as vivid red colour. The chart is a set of 342 big solid circle points of which about 92% can be seen. It has alpha set to 0.8. The three species form clusters, but they are not separated. Adelie is at low left, Gentoo is upper right, and Chinstrap is middle and mid-to-upper positions. "></p>
</figure>
</div>
</div>
</div>
<p><br></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:40%;">
<p>What do you see?</p>
<div class="fragment">
<p>There a difference between the groups</p>
<p>✓ location <br> ✗ shape <br> ✓ outliers/anomalies</p>
</div>
<div class="fragment">
<p><br> <span style="color: #F5191C;"> Are you sure? </span></p>
</div>
</div></div>
</section>
<section id="what-is-your-plot-testing-33" class="slide level2">
<h2>What is your plot testing? <span class="f50">(3/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb15"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb15-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>() <span class="sc">+</span> </span>
<span id="cb15-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_tile</span>(DATA, </span>
<span id="cb15-3"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>LONGITUDE, </span>
<span id="cb15-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>LATITUDE, </span>
<span id="cb15-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">fill=</span>VAR1)) <span class="sc">+</span></span>
<span id="cb15-6"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_path</span>(MAP, </span>
<span id="cb15-7"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>LONGITUDE, </span>
<span id="cb15-8"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>LATITUDE,</span>
<span id="cb15-9"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">group=</span>GROUP)) <span class="sc">+</span></span>
<span id="cb15-10"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">theme_map</span>() </span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br> What will we be assessing using this plot?</p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:40%;">
<div class="fragment">
<p><br> Is there a spatial trend?</p>
<p><br> Are there any spatial anomalies?</p>
</div>
</div></div>
</section>
<section id="what-is-your-plot-testing-33-1" class="slide level2">
<h2>What is your plot testing? <span class="f50">(3/3)</span></h2>
<div class="columns">
<div class="column" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-35-1.png" class="quarto-figure quarto-figure-center" style="width:100.0%"></p>
</figure>
</div>
</div>
</div>
<p><br></p>
</div><div class="column" style="width:10%;">
</div><div class="column" style="width:40%;">
<p>What do you see?</p>
<div class="fragment">
<p>There are clusters of high and low temperature in different parts of the region.</p>
<p>✓ clusters <br> ✓ outliers/anomalies</p>
</div>
<div class="fragment">
<p><br> <span style="color: #F5191C;"> Are you sure? </span></p>
</div>
</div></div>
</section>
<section id="null-hypothesis-example-1" class="slide level2">
<h2>Null hypothesis, example 1</h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb16"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb16-1"><a href="" aria-hidden="true" tabindex="-1"></a>LM_FIT <span class="ot"><-</span> <span class="fu">lm</span>(VAR2 <span class="sc">~</span> VAR1, </span>
<span id="cb16-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">data =</span> DATA)</span>
<span id="cb16-3"><a href="" aria-hidden="true" tabindex="-1"></a>FIT_ALL <span class="ot"><-</span> <span class="fu">augment</span>(LM_FIT)</span>
<span id="cb16-4"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(FIT_ALL, <span class="fu">aes</span>(<span class="at">x=</span>.FITTED, </span>
<span id="cb16-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>.RESID)) <span class="sc">+</span> </span>
<span id="cb16-6"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br> What is the null hypothesis?</p>
<div class="fragment">
<p><em>There is no relationship between residuals and fitted values.</em> This is <span class="math inline">\(H_o\)</span>.</p>
</div>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:45%;">
<div class="fragment f80">
<p><br><br><br></p>
<p><strong>Alternative hypothesis</strong>, <span class="math inline">\(H_a\)</span>:</p>
<p><em>There is some relationship</em>, which might be</p>
<ul>
<li>non-linearity</li>
<li>heteroskedasticity</li>
<li>outliers/anomalies</li>
</ul>
</div>
</div></div>
</section>
<section id="null-hypothesis-example-2" class="slide level2">
<h2>Null hypothesis, example 2</h2>
<div class="columns">
<div class="column" style="width:50%;">
<p><br></p>
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb17"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb17-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(DATA, </span>
<span id="cb17-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>VAR1, </span>
<span id="cb17-3"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>VAR2, </span>
<span id="cb17-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">color=</span>CLASS)) <span class="sc">+</span> </span>
<span id="cb17-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br> What is the null hypothesis?</p>
<div class="fragment">
<p><em>There is no difference between the classes.</em> This is <span class="math inline">\(H_o\)</span>.</p>
</div>
</div><div class="column" style="width:5%;">
</div><div class="column" style="width:45%;">
<div class="fragment f80">
<p><br><br><br> <strong>Alternative hypothesis</strong>, <span class="math inline">\(H_a\)</span>:</p>
<p><em>There is some difference between the classes</em>, which might be</p>
<ul>
<li>location</li>
<li>shape</li>
<li>outliers/anomalies</li>
</ul>
</div>
</div></div>
</section>
<section id="creating-null-samples" class="slide level2 transition center">
<h2>Creating null samples</h2>
</section>
<section id="creating-null-samples-example-1" class="slide level2">
<h2>Creating null samples, example 1</h2>
<div class="columns">
<div class="column f80" style="width:50%;">
<div class="cell" data-layout-align="center">
<div class="sourceCode cell-code" id="cb18"><pre class="sourceCode r code-with-copy"><code class="sourceCode r"><span id="cb18-1"><a href="" aria-hidden="true" tabindex="-1"></a><span class="fu">ggplot</span>(DATA, </span>
<span id="cb18-2"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">aes</span>(<span class="at">x=</span>VAR1, </span>
<span id="cb18-3"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">y=</span>VAR2, </span>
<span id="cb18-4"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="at">color=</span>CLASS)) <span class="sc">+</span> </span>
<span id="cb18-5"><a href="" aria-hidden="true" tabindex="-1"></a> <span class="fu">geom_point</span>()</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
</div>
<p><br></p>
<p><span class="math inline">\(H_o\)</span>: <em>There is no difference between the classes.</em></p>
<div class="fragment">
<p>How would you generate null samples?</p>
</div>
<div class="fragment">
<p><br> Break any association by permuting (scrambling/shuffling/re-sampling) the CLASS variable.</p>
</div>
</div><div class="column" style="width:50%;">
<div class="fragment">
<div class="cell" data-layout-align="center">
<div class="cell-output-display">
<div class="quarto-figure quarto-figure-center">
<figure>
<p><img data-src="slides_files/figure-revealjs/unnamed-chunk-39-1.png" class="quarto-figure quarto-figure-center" style="width:60.0%" alt="Top plot is the same as that plotted on slide 33. Bottom plot has points coloured on permuted class, and the clusters so not match the colors."></p>
</figure>
</div>
</div>