-
Notifications
You must be signed in to change notification settings - Fork 1
/
r4r_visualisation_slides.html
1869 lines (1569 loc) · 57 KB
/
r4r_visualisation_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="" xml:lang="">
<head>
<title>R for Archaeologists</title>
<meta charset="utf-8" />
<script src="libs/header-attrs/header-attrs.js"></script>
<link rel="stylesheet" href="xaringan-themer.css" type="text/css" />
</head>
<body>
<textarea id="source">
class: center, middle, inverse, title-slide
.title[
# R for Archaeologists
]
.subtitle[
## Visualisation
]
---
class: middle
background-image: url("figures/jr-survey.png")
background-size: 67%
.pull-left[
![](https://joeroe.io/images/avatar.png)
**Joe Roe**
University of Bern
* <svg aria-hidden="true" role="img" viewBox="0 0 640 512" style="height:1em;width:1.25em;vertical-align:-0.125em;margin-left:auto;margin-right:auto;font-size:inherit;fill:currentColor;overflow:visible;position:relative;"><path d="M579.8 267.7c56.5-56.5 56.5-148 0-204.5c-50-50-128.8-56.5-186.3-15.4l-1.6 1.1c-14.4 10.3-17.7 30.3-7.4 44.6s30.3 17.7 44.6 7.4l1.6-1.1c32.1-22.9 76-19.3 103.8 8.6c31.5 31.5 31.5 82.5 0 114L422.3 334.8c-31.5 31.5-82.5 31.5-114 0c-27.9-27.9-31.5-71.8-8.6-103.8l1.1-1.6c10.3-14.4 6.9-34.4-7.4-44.6s-34.4-6.9-44.6 7.4l-1.1 1.6C206.5 251.2 213 330 263 380c56.5 56.5 148 56.5 204.5 0L579.8 267.7zM60.2 244.3c-56.5 56.5-56.5 148 0 204.5c50 50 128.8 56.5 186.3 15.4l1.6-1.1c14.4-10.3 17.7-30.3 7.4-44.6s-30.3-17.7-44.6-7.4l-1.6 1.1c-32.1 22.9-76 19.3-103.8-8.6C74 372 74 321 105.5 289.5L217.7 177.2c31.5-31.5 82.5-31.5 114 0c27.9 27.9 31.5 71.8 8.6 103.9l-1.1 1.6c-10.3 14.4-6.9 34.4 7.4 44.6s34.4 6.9 44.6-7.4l1.1-1.6C433.5 260.8 427 182 377 132c-56.5-56.5-148-56.5-204.5 0L60.2 244.3z"/></svg> [joeroe.io](https://joeroe.io)
* <svg aria-hidden="true" role="img" viewBox="0 0 496 512" style="height:1em;width:0.97em;vertical-align:-0.125em;margin-left:auto;margin-right:auto;font-size:inherit;fill:currentColor;overflow:visible;position:relative;"><path d="M165.9 397.4c0 2-2.3 3.6-5.2 3.6-3.3.3-5.6-1.3-5.6-3.6 0-2 2.3-3.6 5.2-3.6 3-.3 5.6 1.3 5.6 3.6zm-31.1-4.5c-.7 2 1.3 4.3 4.3 4.9 2.6 1 5.6 0 6.2-2s-1.3-4.3-4.3-5.2c-2.6-.7-5.5.3-6.2 2.3zm44.2-1.7c-2.9.7-4.9 2.6-4.6 4.9.3 2 2.9 3.3 5.9 2.6 2.9-.7 4.9-2.6 4.6-4.6-.3-1.9-3-3.2-5.9-2.9zM244.8 8C106.1 8 0 113.3 0 252c0 110.9 69.8 205.8 169.5 239.2 12.8 2.3 17.3-5.6 17.3-12.1 0-6.2-.3-40.4-.3-61.4 0 0-70 15-84.7-29.8 0 0-11.4-29.1-27.8-36.6 0 0-22.9-15.7 1.6-15.4 0 0 24.9 2 38.6 25.8 21.9 38.6 58.6 27.5 72.9 20.9 2.3-16 8.8-27.1 16-33.7-55.9-6.2-112.3-14.3-112.3-110.5 0-27.5 7.6-41.3 23.6-58.9-2.6-6.5-11.1-33.3 2.6-67.9 20.9-6.5 69 27 69 27 20-5.6 41.5-8.5 62.8-8.5s42.8 2.9 62.8 8.5c0 0 48.1-33.6 69-27 13.7 34.7 5.2 61.4 2.6 67.9 16 17.7 25.8 31.5 25.8 58.9 0 96.5-58.9 104.2-114.8 110.5 9.2 7.9 17 22.9 17 46.4 0 33.7-.3 75.4-.3 83.6 0 6.5 4.6 14.4 17.3 12.1C428.2 457.8 496 362.9 496 252 496 113.3 383.5 8 244.8 8zM97.2 352.9c-1.3 1-1 3.3.7 5.2 1.6 1.6 3.9 2.3 5.2 1 1.3-1 1-3.3-.7-5.2-1.6-1.6-3.9-2.3-5.2-1zm-10.8-8.1c-.7 1.3.3 2.9 2.3 3.9 1.6 1 3.6.7 4.3-.7.7-1.3-.3-2.9-2.3-3.9-2-.6-3.6-.3-4.3.7zm32.4 35.6c-1.6 1.3-1 4.3 1.3 6.2 2.3 2.3 5.2 2.6 6.5 1 1.3-1.3.7-4.3-1.3-6.2-2.2-2.3-5.2-2.6-6.5-1zm-11.4-14.7c-1.6 1-1.6 3.6 0 5.9 1.6 2.3 4.3 3.3 5.6 2.3 1.6-1.3 1.6-3.9 0-6.2-1.4-2.3-4-3.3-5.6-2z"/></svg> [joeroe](https://github.com/joeroe)
* <svg aria-hidden="true" role="img" viewBox="0 0 512 512" style="height:1em;width:1em;vertical-align:-0.125em;margin-left:auto;margin-right:auto;font-size:inherit;fill:currentColor;overflow:visible;position:relative;"><path d="M459.37 151.716c.325 4.548.325 9.097.325 13.645 0 138.72-105.583 298.558-298.558 298.558-59.452 0-114.68-17.219-161.137-47.106 8.447.974 16.568 1.299 25.34 1.299 49.055 0 94.213-16.568 130.274-44.832-46.132-.975-84.792-31.188-98.112-72.772 6.498.974 12.995 1.624 19.818 1.624 9.421 0 18.843-1.3 27.614-3.573-48.081-9.747-84.143-51.98-84.143-102.985v-1.299c13.969 7.797 30.214 12.67 47.431 13.319-28.264-18.843-46.781-51.005-46.781-87.391 0-19.492 5.197-37.36 14.294-52.954 51.655 63.675 129.3 105.258 216.365 109.807-1.624-7.797-2.599-15.918-2.599-24.04 0-57.828 46.782-104.934 104.934-104.934 30.213 0 57.502 12.67 76.67 33.137 23.715-4.548 46.456-13.32 66.599-25.34-7.798 24.366-24.366 44.833-46.132 57.827 21.117-2.273 41.584-8.122 60.426-16.243-14.292 20.791-32.161 39.308-52.628 54.253z"/></svg> [@joeroe](https://twitter.com/joeroe90)
]
.pull-right[
![](figures/jr-palecomod.png)
![](figures/jr-c14.png)
]
???
* Introducing myself
---
class: center, middle
<div id="svxgpepdlq" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#svxgpepdlq table {
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#svxgpepdlq thead, #svxgpepdlq tbody, #svxgpepdlq tfoot, #svxgpepdlq tr, #svxgpepdlq td, #svxgpepdlq th {
border-style: none;
}
#svxgpepdlq p {
margin: 0;
padding: 0;
}
#svxgpepdlq .gt_table {
display: table;
border-collapse: collapse;
line-height: normal;
margin-left: auto;
margin-right: auto;
color: #333333;
font-size: 16px;
font-weight: normal;
font-style: normal;
background-color: #FFFFFF;
width: auto;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #A8A8A8;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #A8A8A8;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
}
#svxgpepdlq .gt_caption {
padding-top: 4px;
padding-bottom: 4px;
}
#svxgpepdlq .gt_title {
color: #333333;
font-size: 125%;
font-weight: initial;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
border-bottom-color: #FFFFFF;
border-bottom-width: 0;
}
#svxgpepdlq .gt_subtitle {
color: #333333;
font-size: 85%;
font-weight: initial;
padding-top: 3px;
padding-bottom: 5px;
padding-left: 5px;
padding-right: 5px;
border-top-color: #FFFFFF;
border-top-width: 0;
}
#svxgpepdlq .gt_heading {
background-color: #FFFFFF;
text-align: center;
border-bottom-color: #FFFFFF;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
#svxgpepdlq .gt_bottom_border {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#svxgpepdlq .gt_col_headings {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
}
#svxgpepdlq .gt_col_heading {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 6px;
padding-left: 5px;
padding-right: 5px;
overflow-x: hidden;
}
#svxgpepdlq .gt_column_spanner_outer {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: normal;
text-transform: inherit;
padding-top: 0;
padding-bottom: 0;
padding-left: 4px;
padding-right: 4px;
}
#svxgpepdlq .gt_column_spanner_outer:first-child {
padding-left: 0;
}
#svxgpepdlq .gt_column_spanner_outer:last-child {
padding-right: 0;
}
#svxgpepdlq .gt_column_spanner {
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: bottom;
padding-top: 5px;
padding-bottom: 5px;
overflow-x: hidden;
display: inline-block;
width: 100%;
}
#svxgpepdlq .gt_spanner_row {
border-bottom-style: hidden;
}
#svxgpepdlq .gt_group_heading {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
text-align: left;
}
#svxgpepdlq .gt_empty_group_heading {
padding: 0.5px;
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
vertical-align: middle;
}
#svxgpepdlq .gt_from_md > :first-child {
margin-top: 0;
}
#svxgpepdlq .gt_from_md > :last-child {
margin-bottom: 0;
}
#svxgpepdlq .gt_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
margin: 10px;
border-top-style: solid;
border-top-width: 1px;
border-top-color: #D3D3D3;
border-left-style: none;
border-left-width: 1px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 1px;
border-right-color: #D3D3D3;
vertical-align: middle;
overflow-x: hidden;
}
#svxgpepdlq .gt_stub {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
}
#svxgpepdlq .gt_stub_row_group {
color: #333333;
background-color: #FFFFFF;
font-size: 100%;
font-weight: initial;
text-transform: inherit;
border-right-style: solid;
border-right-width: 2px;
border-right-color: #D3D3D3;
padding-left: 5px;
padding-right: 5px;
vertical-align: top;
}
#svxgpepdlq .gt_row_group_first td {
border-top-width: 2px;
}
#svxgpepdlq .gt_row_group_first th {
border-top-width: 2px;
}
#svxgpepdlq .gt_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
#svxgpepdlq .gt_first_summary_row {
border-top-style: solid;
border-top-color: #D3D3D3;
}
#svxgpepdlq .gt_first_summary_row.thick {
border-top-width: 2px;
}
#svxgpepdlq .gt_last_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#svxgpepdlq .gt_grand_summary_row {
color: #333333;
background-color: #FFFFFF;
text-transform: inherit;
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
}
#svxgpepdlq .gt_first_grand_summary_row {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-top-style: double;
border-top-width: 6px;
border-top-color: #D3D3D3;
}
#svxgpepdlq .gt_last_grand_summary_row_top {
padding-top: 8px;
padding-bottom: 8px;
padding-left: 5px;
padding-right: 5px;
border-bottom-style: double;
border-bottom-width: 6px;
border-bottom-color: #D3D3D3;
}
#svxgpepdlq .gt_striped {
background-color: rgba(128, 128, 128, 0.05);
}
#svxgpepdlq .gt_table_body {
border-top-style: solid;
border-top-width: 2px;
border-top-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
}
#svxgpepdlq .gt_footnotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
#svxgpepdlq .gt_footnote {
margin: 0px;
font-size: 90%;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
}
#svxgpepdlq .gt_sourcenotes {
color: #333333;
background-color: #FFFFFF;
border-bottom-style: none;
border-bottom-width: 2px;
border-bottom-color: #D3D3D3;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
}
#svxgpepdlq .gt_sourcenote {
font-size: 90%;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
}
#svxgpepdlq .gt_left {
text-align: left;
}
#svxgpepdlq .gt_center {
text-align: center;
}
#svxgpepdlq .gt_right {
text-align: right;
font-variant-numeric: tabular-nums;
}
#svxgpepdlq .gt_font_normal {
font-weight: normal;
}
#svxgpepdlq .gt_font_bold {
font-weight: bold;
}
#svxgpepdlq .gt_font_italic {
font-style: italic;
}
#svxgpepdlq .gt_super {
font-size: 65%;
}
#svxgpepdlq .gt_footnote_marks {
font-size: 75%;
vertical-align: 0.4em;
position: initial;
}
#svxgpepdlq .gt_asterisk {
font-size: 100%;
vertical-align: 0;
}
#svxgpepdlq .gt_indent_1 {
text-indent: 5px;
}
#svxgpepdlq .gt_indent_2 {
text-indent: 10px;
}
#svxgpepdlq .gt_indent_3 {
text-indent: 15px;
}
#svxgpepdlq .gt_indent_4 {
text-indent: 20px;
}
#svxgpepdlq .gt_indent_5 {
text-indent: 25px;
}
</style>
<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">
<thead>
<tr class="gt_col_headings">
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" style="font-weight: bold;" scope="col" id="Day">Day</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" style="font-weight: bold;" scope="col" id="Time">Time</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" style="font-weight: bold;" scope="col" id="Topics">Topics</th>
<th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" style="font-weight: bold;" scope="col" id="Exercises">Exercises</th>
</tr>
</thead>
<tbody class="gt_table_body">
<tr><td headers="Day" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>Thursday</p>
</div></td>
<td headers="Time" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>10–13</p>
</div></td>
<td headers="Topics" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><strong>Introduction to visualisation in R</strong></p>
<ul>
<li>Visualisation in data science</li>
<li>Overview of R graphics packages</li>
<li>ggplot2: The ‘grammar of graphics’</li>
</ul>
</div></td>
<td headers="Exercises" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><em>R for Data Science</em>, ch. 3</p>
</div></td></tr>
<tr><td headers="Day" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'></div></td>
<td headers="Time" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>14–17</p>
</div></td>
<td headers="Topics" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><strong>Visualisation for Exploratory Data Analysis</strong></p>
<ul>
<li>Applications in archaeology</li>
<li>Visualising ‘tidy data’</li>
<li><code>ggplot2</code> for EDA</li>
</ul>
</div></td>
<td headers="Exercises" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><em>R for Data Science</em>, ch. 7 & 11</p>
</div></td></tr>
<tr><td headers="Day" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>Friday</p>
</div></td>
<td headers="Time" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>10–13</p>
</div></td>
<td headers="Topics" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><strong>Advanced visualisation exercises</strong></p>
<ul>
<li>Tables: <code>gt</code></li>
<li>Radiocarbon: <code>ggridges</code></li>
<li>Cartography: <code>ggspatial</code></li>
<li>3D: <code>rayshader</code></li>
</ul>
</div></td>
<td headers="Exercises" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><em>Groupwork</em></p>
</div></td></tr>
<tr><td headers="Day" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'></div></td>
<td headers="Time" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top; font-weight: bold;"><div class='gt_from_md'><p>14–17</p>
</div></td>
<td headers="Topics" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><strong>Publication-ready visualisation</strong></p>
<ul>
<li>What makes an effective graphic?</li>
<li>Advanced <code>ggplot2</code>: aesthetics and themes</li>
<li>Tips for the real world</li>
</ul>
</div></td>
<td headers="Exercises" class="gt_row gt_left" style="font-size: small; text-align: left; vertical-align: top;"><div class='gt_from_md'><p><em>R for Data Science</em>, ch. 28</p>
</div></td></tr>
</tbody>
</table>
</div>
???
* The "Visualisation" module follows on from the introduction to R you've had so far
* We'll start by outlining the through the two major graphics packages in R: "base" and `ggplot2`
*
* Then tomorrow, we'll look at some specific "advanced" visualisation techniques relevant to archaeology:
* First spatial visualisations and mapping, following on from last week's module on spatial analysis
* Then a selection of other specific applications – subject to change!
* And finally, on Wednesday, we'll discuss preparing plots ready for final publication
* I would like this to be as hands-on as possible, so the format for this module is you doing exercises at your own pace, with me dropping in to explain things as needed
---
class: center, middle
View these slides online:
<https://joeroe.io/r4r_visualisation/r4r_visualisation_slides.html>
Source code:
<https://github.com/joeroe/r4r_visualisation>
<small>They're written in RMarkdown!</small>
---
class: inverse, center, middle
# Visualisation with R
## Introduction
???
* Why use R for visualisations? Or: why did we devote a quarter of this course to visualisation?
* Most of you are probably here because, in some way or other, you want to use R to "do statistics"
* As you go up the admittedly steeper learning curve of visualisations in R, you might ask: why not just export the result to a more intuitive programme like Excel, and make the plots there?
* For that I have three answers:
* (or four: the zeroth being because Excel is bad software, don't use it)
---
class: center, middle
![](figures/data-science.png)
.center[<small>Data science workflow. After Wickham & Grolemund, *R for Data Science*</small>]
???
* First—and this is why we are we looking at visualisations now, rather than at the end—is that visualisation is not just the end product of a statistical analysis, something you use to **communicate**, but right at its centre, as something that helps us **understand**.
* In the exploratory data analysis (EDA) or modern "data science" workflow (illustrated very nicely here in a figure from Hadley Wickham's *R for Data Science*), visualisation is one of the pillars of data analysis
* You should use graphics often, to help you understand data as you go through the iterative cycle of interrogating and modelling it
---
class: center, middle
.pull-left[
![](figures/tukey-eda.jpg)
]
.pull-right[
![](figures/r4ds.jpg)
]
???
* This is an old idea: starting with 'exploratory data analysis', and continued in modern 'data science'
* Computers obviously make it a lot easier to generate plots quickly;
* And R was in fact originally designed to facilitate EDA, so it's very well suited for it: once you've mastered the basic graphics functions, you can generate plots easily and often
---
class: middle
# R: a statistical *programming language*
1. Iterate
2. Scale
3. Reproduce
???
* Second, R is a statisical *programming language*. This has powerful advantages compared to traditional workflows for producing plots:
* Iteration: generate your final plot and realise you need to change something in the source data? No problem!
* Scalability: write code to visualise X about Y; then run it on 1000 (or 10000, or 100000) values of Y
* Reproducibility: everybody can see exactly the steps you took to produce a plot
---
class: center, middle
## `bbplot` <<https://github.com/bbc/bbplot>>
![](figures/bbplot_example_plots.png)
???
* Third, R graphics simply do look very nice. Maybe not always 'out of the box', but the capability is there.
* For example, ... all use R for their statistical graphics
---
# Graphics packages in R
```r
library("archdata")
data("BACups")
```
.pull-left[
<img src="r4r_visualisation_slides_files/figure-html/plot-demo-base-1.png" width="100%" />
```r
plot(BACups$H, BACups$RD)
```
]
.pull-right[
<img src="r4r_visualisation_slides_files/figure-html/plot-demo-ggplot-1.png" width="100%" />
```r
ggplot(BACups, aes(x = H, y = RD)) +
geom_point()
```
]
???
* There isn't one way to produce plots in R: you have to pick a **graphics package**
* The main options are "base" (actually `graphics`), `ggplot2`, and `lattice` (now rarely used)
* These packages have major differences in syntax, and by extension flexibility and capabilities
---
.pull-left[
<img src="r4r_visualisation_slides_files/figure-html/plot-demo-base-ext-1.png" width="100%" />
```r
par(mfrow = c(1,2))
plot(BACups[BACups$Phase=="Protoapennine",]$H,
BACups[BACups$Phase=="Protoapennine",]$RD,
cex = BACups[BACups$Phase=="Protoapennine",]$ND / 10,
main = "Bronze Age cups",
sub = "Protoapennine",
xlab = "Height",
ylab = "Rim Diameter")
plot(BACups[BACups$Phase=="Subapennine",]$H,
BACups[BACups$Phase=="Subapennine",]$RD,
cex = BACups[BACups$Phase=="Subapennine",]$ND / 10,
main = "(Data from Lukesh and Howe 1978)",
sub = "Subapennine",
xlab = "Height",
ylab = "Rim Diameter")
legend("bottomright",
title = "Neck Diameter",
pch = 1,
legend = c(10, 15, 20, 25),
pt.cex = c(1, 1.5, 2, 2.5))
```
]
.pull-right[
<img src="r4r_visualisation_slides_files/figure-html/plot-demo-ggplot-ext-1.png" width="100%" />
```r
ggplot(BACups, aes(x = H, y = RD, size = ND)) +
geom_point(shape = 1) +
facet_wrap(vars(Phase)) +
labs(x = "Height",
y = "Rim Diameter",
size = "Neck Diameter",
title = "Bronze Age cups",
subtitle = "Data from Lukesh and Howe (1978)")
```
]
???
* These differences are highlighted when you try to do more complex plots
* Don't get hung up on the aesthetic differences – these are defaults, you can easily make one look like the other (or anything else)
* There is some debate over the pros and cons of each – I see ggplot2 as a straightforward upgrade and from this afternoon we will focus on its approach
* But it's helpful to be familiar with base as the 'default' in a lot of cases, e.g. used by many packages to plot complex data structures, so we'll start with that
---
class: inverse, center, middle
# `ggplot2`: the 'grammar of graphics'
???
* `ggplot2` is based on the "grammar of graphics"
* This is a somewhat theoretical concept. Further reading:
* Wickham 2010, *A Layered Grammar of Graphics*
* Wilkinson, Anand & Grossman 2005, *The Grammar of Graphics*
* But it's helpful to have some idea of that theory, to make sense of random prefixes like "aes" or "geom"
---
class: center, middle
# The Grammar of Graphics
![](figures/grammar-of-graphics.png)
???
* The grammer is a structured way of *describing* the relationship between data and graphical elements (declarative) – as opposed to `base` graphics, which is you *telling* R what to plot (imperative)
* Specifically, `ggplot` introduces a *layered* grammer of graphics, allowing you to combine multiple mappings into a single plot
* This makes it much more flexible than base and allows us to maintain readable code for even very complicated plots
* Downsides: data does have to be in a roughly tabular (if not fully "tidy") structure to work well with ggplot. Complex objects from other packages can be a challenge to work with.
* For EDA purposes, it's often better to fall back on `base::plot()` with these objects
* Though packages like `broom` can help
---
# Plotting with `ggplot2`: exercises
**Wickham & Grolemund, *R for data science***
https://r4ds.had.co.nz/
Chapter 3: *Data visualisation*
Chapter 7: *Exploratory Data Analysis* (if you have time)
* Install the `tidyverse` metapackage
* Run Hadley's code examples
* Answer questions as comments (`# Here is my answer...`)
* Do the 'exercises' sections – they're very informative!
---
# Plotting with `ggplot2`: applications?
.pull-left[
<img src="r4r_visualisation_slides_files/figure-html/ggplot-scatter-1.png" width="100%" />
<img src="r4r_visualisation_slides_files/figure-html/ggplot-smooth-1.png" width="100%" />
]
.pull-right[
<img src="r4r_visualisation_slides_files/figure-html/ggplot-bar-1.png" width="100%" />
<img src="r4r_visualisation_slides_files/figure-html/ggplot-boxplot-1.png" width="100%" />
]
???
* We've seen how to do a few fundamental plots with ``ggplot2` this morning, but using "dummy" datasets like `cars` and `diamonds`.
* What are some archaeological applications of these plots?
* Tomorrow we will look at some more niche types of visualisation in archaeology;
* For now, we continue to work on the fundamentals of using visualisation EDA
---
class: middle
# Tidy data
![](figures/r4rds-tidy-1.png)
???
* As I mentioned this morning, a big part of producing graphics effectively is having the tools to transform data to the right format
* And `ggplot2` is generally super-charged when used as part of a "tidy data analysis" workflow
* With the example data you've used so far, this has been done for you. With "real world" archaeology data, it won't be!
---
# Plotting with tidy data
.pull-left[
```r
data("emedyd") # From rcarbon
emedyd %>%
filter(SiteName == "Wadi Jilat 13") %>%
arrange(CRA) %>%
mutate(LabID = as_factor(LabID)) %>%
mutate(CalDate = cal(CRA, Error, verbose = FALSE)) %>%
unnest_legacy() %>%
ggplot(aes(calBP, PrDens)) +
facet_wrap(~LabID, ncol = 1,
scales = "free_y",
strip.position = "left") +
geom_area() +
scale_x_reverse(name = "cal BP") +
scale_y_continuous(labels = NULL, name = NULL) +
labs(title = "Wadi Jilat 13",
subtitle = "Radiocarbon chronology")
```
]
.pull-right[
<img src="r4r_visualisation_slides_files/figure-html/tidy-rcarbon-1.png" width="100%" />
]
???
* For example, *pipes* allow us to elegantly and concisely load data, clean and filter, and plot in a single code block
* Half of the code here—the most important half—is *reshaping* the data before even giving it to the plot. Often, it's more than half!
* You can read more about reshaping or "wrangling" data in *R for Data Science*
---
# `ggplot2` for EDA: exercises
**Wickham & Grolemund, *R for data science***
https://r4ds.had.co.nz/
Chapter 3: *Data visualisation* (if you haven't finished)
Chapter 7: *Exploratory Data Analysis*
Chapter 12: *Tidy data* (if you have time)
* Run Hadley's code examples
* Answer questions as comments (`# Here is my answer...`)
* Do the 'exercises' sections – they're very informative!
---
class: inverse, center, middle
# Advanced visualisations
## Plotting archaeological data
---
class: inverse, center, middle
# CartogRaphy
## Mapping with `ggplot2` and friends
---
class: center, middle
# R as a GIS
## (R isn't a GIS)
---
# R spatial ecosystem
.pull-left[
* Spatial data
* `rgdal`, `rgeos`, `rgrass7`, `link2gi`
* `sf`, `sp`
* `raster`, `stars`, `terra`
* Geostatistics
* `spatstat`, `gstat`, `spdep`, `nlme`
* `landsat`, `dismo`
]
.pull-right[
* Base maps + open data
* `maps`, `maptools`, `rnaturalearth`
* `ggmap`, `leaflet`, `mapview`
* `rOpenSci`
* Cartography
* `ggplot2`
* `ggspatial`
* `rasterVis`
* `tmap`
]
---
# Mapping with `ggplot2`: exercises (1/2)
**Wickham, Navarro & Pedersen, *ggplot2: Elegant Graphics for Data Analysis***
https://ggplot2-book.org/
Chapter 6: *Maps*
* Run the code examples
* Reproduce the following using the 'tavo-a27' dataset.
* Hint: In addition to `ggplot2`, you will need the `raster` and `ggspatial` packages.
---
class: center, middle
<img src="r4r_visualisation_slides_files/figure-html/eg-tavo-1.png" width="100%" />
---
# Tables (`gt`)
## The forgotten visualisation
<div id="npzqtpzxze" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">
<style>#npzqtpzxze table {
font-family: system-ui, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
#npzqtpzxze thead, #npzqtpzxze tbody, #npzqtpzxze tfoot, #npzqtpzxze tr, #npzqtpzxze td, #npzqtpzxze th {
border-style: none;
}
#npzqtpzxze p {
margin: 0;
padding: 0;
}
#npzqtpzxze .gt_table {
display: table;
border-collapse: collapse;
line-height: normal;
margin-left: auto;
margin-right: auto;
color: #333333;
font-size: 16px;
font-weight: normal;
font-style: normal;
background-color: #FFFFFF;
width: auto;
border-top-style: solid;
border-top-width: 2px;
border-top-color: #A8A8A8;
border-right-style: none;
border-right-width: 2px;
border-right-color: #D3D3D3;
border-bottom-style: solid;
border-bottom-width: 2px;
border-bottom-color: #A8A8A8;
border-left-style: none;
border-left-width: 2px;
border-left-color: #D3D3D3;
}
#npzqtpzxze .gt_caption {
padding-top: 4px;
padding-bottom: 4px;
}
#npzqtpzxze .gt_title {
color: #333333;
font-size: 125%;
font-weight: initial;
padding-top: 4px;
padding-bottom: 4px;
padding-left: 5px;
padding-right: 5px;
border-bottom-color: #FFFFFF;
border-bottom-width: 0;
}
#npzqtpzxze .gt_subtitle {
color: #333333;
font-size: 85%;
font-weight: initial;