-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathBiodiversity_Alberta.html
More file actions
1322 lines (1231 loc) · 153 KB
/
Biodiversity_Alberta.html
File metadata and controls
1322 lines (1231 loc) · 153 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="pandoc" />
<meta name="date" content="2022-09-25" />
<meta name="progressive" content="false" />
<meta name="allow-skip" content="false" />
<meta name="learnr-version-prerender" content="0.10.5.9000" />
<title>Alberta Trees Tutorial</title>
<!-- header-includes START -->
<!-- HEAD_CONTENT -->
<!-- header-includes END -->
<!-- HEAD_CONTENT -->
<!-- highlightjs -->
<style type="text/css">code{white-space: pre;}</style>
<style type="text/css">
pre:not([class]) {
background-color: white;
}
</style>
<script type="text/javascript">
if (window.hljs) {
hljs.configure({languages: []});
hljs.initHighlightingOnLoad();
if (document.readyState && document.readyState === "complete") {
window.setTimeout(function() { hljs.initHighlighting(); }, 0);
}
}
</script>
<!-- taken from https://github.com/rstudio/rmarkdown/blob/de8a9c38618903627ca509f5401d50a0876079f7/inst/rmd/h/default.html#L293-L343 -->
<!-- tabsets -->
<style type="text/css">
.tabset-dropdown > .nav-tabs {
display: inline-table;
max-height: 500px;
min-height: 44px;
overflow-y: auto;
border: 1px solid #ddd;
border-radius: 4px;
}
.tabset-dropdown > .nav-tabs > li.active:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li.active:before {
content: "";
border: none;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open:before {
content: "";
font-family: 'Glyphicons Halflings';
display: inline-block;
padding: 10px;
border-right: 1px solid #ddd;
}
.tabset-dropdown > .nav-tabs > li.active {
display: block;
}
.tabset-dropdown > .nav-tabs > li > a,
.tabset-dropdown > .nav-tabs > li > a:focus,
.tabset-dropdown > .nav-tabs > li > a:hover {
border: none;
display: inline-block;
border-radius: 4px;
background-color: transparent;
}
.tabset-dropdown > .nav-tabs.nav-tabs-open > li {
display: block;
float: none;
}
.tabset-dropdown > .nav-tabs > li {
display: none;
}
</style>
<!-- end tabsets -->
</head>
<body>
<a class='sr-only sr-only-focusable visually-hidden-focusable' href='#learnr-tutorial-content'>Skip to Tutorial Content</a>
<div class="pageContent band">
<main class="bandContent page">
<article class="topics" id="learnr-tutorial-content">
<div id="section-tutorial-objectives" class="section level2">
<h2><strong>Tutorial objectives</strong></h2>
<p>Forestry and ecology students are the optimal audience to follow this
tutorial. Some prerequisites are necessary but not essential, i.e. <a
href="https://www.youtube.com/watch?v=gb4qqX4uhYA">an introduction to
linear regression</a>, <a
href="https://www.youtube.com/watch?v=7UK2DK7rblw">how to read a
boxplot?</a>, <a href="https://www.youtube.com/watch?v=DJzmb7hGmeM">the
Bell Curve (Normal/Gaussian Distribution)</a>, <a
href="https://www.youtube.com/watch?v=J5gRckrv44c">what is a residual
plot?</a>.</p>
<p>At the end of this tutorial you will be able to:</p>
<ol style="list-style-type: decimal">
<li>Contextualize the global and boreal plant diversity
distribution.</li>
<li>Understand the basis of the linear model approach linking plant
diversity, space and environment.</li>
<li>Introduce yourself to the non-linear model relationship in
ecological data.</li>
<li>Debut into the dendrochronology concept in forestry and
ecology.</li>
<li>Explore the tree analysis over time using multiple datasets through
graphic visualization.</li>
</ol>
<p>We will focus on the plant vascular cover diversity and soil
temperature in 2010. We will also use the dendrochronology historical
datasets.</p>
</div>
<div id="section-learning-objectives" class="section level2">
<h2>Learning objectives</h2>
<p>Through this tutorial you will acquire the following skills:</p>
<ol style="list-style-type: decimal">
<li><p>A global understanding of plant biodiversity and dendrochronology
concepts.</p></li>
<li><p>Use real data coming from the Alberta legacy dataset, a project
monitoring diversity in Western Canadian forest, to implement a linear
model approach between diversity and space and environment.</p></li>
<li><p>Explore and interpret data patterns using data exploration, model
codification, selection and validation.</p></li>
<li><p>Familiarize and code by yourself by adapting R code proposed in
this tutorial.</p></li>
</ol>
</div>
<div id="section-alberta-legacy-dataset-background"
class="section level2">
<h2><strong>Alberta legacy dataset background</strong></h2>
<p>An interesting project monitoring diversity was the Seasonal and
annual dynamics of western Canadian boreal forest plant communities: a
legacy dataset spanning four decades. The primary purpose of the
Seasonal Dynamics (SEADYN) and later Annual Dynamics (ANNDYN) research
projects was to document seasonal changes in the vegetative composition
during the snow-free season (May through October) and longer-term
changes in vegetation and forest mensuration for boreal forest stands in
Alberta, Canada dominated by Pinus banksiana (Lamb.) (see central image
in the below figure).</p>
<p>Two regions were used for this study: one in the Hondo-Slave Lake
(hereafter, Hondo) region of Alberta, which was surveyed from 1980 to
2015, and a second location in the Athabasca Oil Sands (hereafter, AOS)
region in northeastern Alberta, which was surveyed from 1981 to 1984 and
thought to have substantial atmospheric pollution due to regional
industrial development (oil sands mining and processing).</p>
<img src="https://github.com/RolandoTrejo/website/blob/main/_lessons/2022-04-07-alberta-trees-tutorial/Images/Alberta_Project.png?raw=true" height="500px" width="100%" data-external="1"/>
<p><em>Photo from Seasonal Dynamics (SEADYN) and later Annual Dynamics
(ANNDYN) research projects metadata, Alberta</em></p>
<div id="section-experimental-design" class="section level3">
<h3><strong>Experimental design</strong></h3>
<p>The experimental design consisted of plots of 50x50 m subdivided into
50 5x5 m quadrants. Data coming from Hondo monitoring can allow us to
state tree questions concerning soil temperature and stands.</p>
<img src="https://github.com/Living-Data-Tutorials/website/blob/main/_lessons/2022-04-07-alberta-trees-tutorial/Location.png?raw=true" height="500px" width="100%" data-external="1"/>
<p><em>Photo from Seasonal Dynamics (SEADYN) and later Annual Dynamics
(ANNDYN) research projects metadata, Alberta</em></p>
</div>
</div>
<div id="section-global-and-boreal-plant-diversity-distribution."
class="section level2" data-progressive="TRUE">
<h2><strong>Global and boreal plant diversity
distribution.</strong></h2>
<p>How BIG is Canada’s Boreal Forest? <em>Video from Boreal Conservation
[<a href="https://www.borealconservation.org"
class="uri">https://www.borealconservation.org</a>]</em></p>
<div class="vembedr" align="center">
<div>
<iframe src="https://www.youtube.com/embed/_XjpzlVVdW8" width="533" height="300" frameborder="0" allowfullscreen="" data-external="1"></iframe>
</div>
</div>
<div id="section-vascular-plant-diversity-what-it-is"
class="section level3">
<h3><strong>Vascular plant diversity: what it is?</strong></h3>
<p>A key concept in biology is Diversity. If you have wondered what is
the connection between species richness of plants versus space and
environment, this is the right place to achieve basic biological and
statistical concepts. There are over 352 000 (391 000 according to Jin
and Qian, 2019) species of vascular plants in the world. More than 95%
of vascular plants are flowering plants, also called angiosperms
(e.g. grasses, orchids, maple trees). The other types of vascular plants
are gymnosperms (cone-bearing trees, e.g. pine trees, spruce trees) and
seedless plants (e.g. ferns, horsetails) (see figure of vascular plants
below) . 5111 species of vascular plants have been found in
Canada(CESCC, 2010). Such an amazing quantity of types and forms of life
definitely invite biologists to wander them selves how diversity works
in nature.</p>
<img src="https://github.com/Living-Data-Tutorials/website/blob/main/_lessons/2022-04-07-alberta-trees-tutorial/Vascular_Plants.png?raw=true" height="500px" width="100%" data-external="1"/>
<p><em>Photos from The Gymnosperm Database and Go Botany (3.7)</em></p>
</div>
</div>
<div
id="section-linear-model-approach-linking-plant-diversity-space-and-environment."
class="section level2">
<h2><strong>Linear model approach linking plant diversity, space and
environment.</strong></h2>
<p>Alberta, including 660 000 km2, is a diverse Canadian province.
Almost 2000 species of vascular plants have been recorded (almost 1500
native) (Packer and Gould, 2017). In order to reveal how biodiversity
connects with space and at least one environmental variable, we will
focus on understanding the effect of stands and soil temperature in
species richness in 2010 regarding only Hondo stands of this
project.Hondo stands are north of Edmonton and east of Lesser Slave
Lake, Alberta (AB), Canada (bottom right map panel). 2010 Hondo vascular
plant is composed by 131 species. In this sites the maximum number of
species found between 1980-2015 was 215. Regarding species diversity, we
can state the following questions:</p>
<pre><code> A. Can we explain vascular diversity regarding soil temperature?
B. Are stands a better predictor than soil temperature?
C. Do we need to consider both variables together to understand vascular plant diversity variation? </code></pre>
<div id="section-data-exploration" class="section level3">
<h3><strong>Data exploration</strong></h3>
<p>In order to answer our questions, we will use data from two different
datasets from long-term tree and plant surveys in Alberta. We can
respond to our questions using data from a specific year. In this
tutorial, we will use 2010 data. Now we can better understand the
regression line provided by graphing soil temperature and species
richness. It basically follows a negative correlation (more species,
less soil temperature). Regarding the boxplot graphic, we can see that
stand 5 and 6 contain more species than stand 3 and 4. In stands 7 and 8
we can visualize outlines (extreme values).</p>
<p><strong>Species richness variation by soil temperature
(°C)</strong></p>
<div id="htmlwidget-60f8362cd111b456dbd8" style="width:624px;height:384px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-60f8362cd111b456dbd8">{"x":{"visdat":{"324d34d34a67":["function () ","plotlyVisDat"]},"cur_data":"324d34d34a67","attrs":{"324d34d34a67":{"x":{},"y":{},"color":"Paired","size":{},"alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"type":"scatter"}},"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"title":"","xaxis":{"domain":[0,1],"automargin":true,"title":"Soil temperature (C)","showgrid":false},"yaxis":{"domain":[0,1],"automargin":true,"title":"Species richness","showgrid":false},"hovermode":"closest","showlegend":false},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"x":[16.66666667,15.55555556,15,15,15,16.11111111,16.11111111,15.55555556,15.55555556,15,16.66666667,15,16.66666667,16.11111111,16.66666667,17.77777778,17.77777778,17.22222222,17.22222222,17.22222222,18.88888889,17.77777778,18.33333333,18.33333333,17.22222222,18.88888889,18.88888889,19.44444444,17.22222222,18.33333333,17.77777778,18.33333333,18.88888889,19.44444444,18.88888889,18.33333333,18.33333333,17.77777778,16.11111111,16.66666667,16.66666667,15.55555556,16.66666667,16.11111111,15.55555556,16.66666667,17.22222222,17.22222222,17.22222222,17.77777778,17.77777778,18.33333333,18.33333333,18.33333333,17.77777778,18.88888889,18.33333333,19.44444444,19.44444444,19.44444444,18.33333333,18.88888889,21.66666667,17.77777778,17.77777778,26.66666667,23.33333333,20.55555556,20,17.77777778,29.44444444,23.33333333,20.55555556,22.22222222,21.66666667,18.33333333,18.88888889,18.88888889,19.44444444,18.88888889,18.88888889,17.22222222,17.77777778,19.44444444,19.44444444,19.44444444,20,18.33333333,18.33333333,17.77777778,18.33333333,19.44444444,18.88888889,19.44444444,18.88888889,18.33333333,18.88888889,17.22222222,18.88888889,17.77777778,15.55555556,15,15.55555556,16.66666667,16.11111111,16.11111111,16.11111111,16.11111111,16.11111111,16.66666667,17.77777778,18.33333333,17.22222222,15.55555556,19.44444444,19.44444444,19.44444444,16.66666667,17.22222222,18.33333333,22.22222222,18.88888889,18.33333333,20.55555556,18.33333333,13.88888889,15.55555556,15.55555556,15,14.44444444,14.44444444,13.88888889,17.77777778,15,14.44444444,15.55555556,16.66666667,16.11111111,15,13.88888889,15,15.55555556,16.11111111,15.55555556,16.11111111,15,15.55555556,15.55555556,13.33333333,16.11111111,18.88888889,16.66666667,18.88888889,15,13.88888889,17.22222222,15.55555556,19.44444444,16.66666667,15.55555556,21.66666667,19.44444444,17.77777778,20,18.88888889,17.22222222,18.33333333,18.88888889,20.55555556,21.11111111,17.77777778,21.11111111,19.44444444,17.22222222,18.88888889],"y":[21,12,16,19,17,19,17,22,18,22,19,18,23,20,22,19,19,20,16,16,15,18,16,16,20,15,16,15,15,14,13,16,17,14,16,17,17,12,13,11,15,15,13,13,11,15,17,13,13,12,15,14,11,7,10,14,11,13,7,9,12,9,13,10,9,9,11,14,6,13,17,14,12,17,14,19,23,24,23,19,23,23,23,22,20,25,21,20,20,18,21,21,21,21,19,22,19,19,24,21,19,24,21,20,29,22,20,25,23,28,23,25,21,27,20,18,21,22,24,25,23,24,26,24,25,18,24,20,20,19,20,18,19,20,24,14,20,17,18,20,17,19,18,18,20,17,18,16,14,18,23,16,16,15,19,17,15,19,24,19,21,16,23,20,21,17,19,15,17,17,17,18,18,15,18],"type":"scatter","mode":"markers","name":"Paired","marker":{"color":"rgba(252,141,98,1)","size":[68.695652173913,33.4782608695652,49.1304347826087,60.8695652173913,53.0434782608696,60.8695652173913,53.0434782608696,72.6086956521739,56.9565217391304,72.6086956521739,60.8695652173913,56.9565217391304,76.5217391304348,64.7826086956522,72.6086956521739,60.8695652173913,60.8695652173913,64.7826086956522,49.1304347826087,49.1304347826087,45.2173913043478,56.9565217391304,49.1304347826087,49.1304347826087,64.7826086956522,45.2173913043478,49.1304347826087,45.2173913043478,45.2173913043478,41.304347826087,37.3913043478261,49.1304347826087,53.0434782608696,41.304347826087,49.1304347826087,53.0434782608696,53.0434782608696,33.4782608695652,37.3913043478261,29.5652173913043,45.2173913043478,45.2173913043478,37.3913043478261,37.3913043478261,29.5652173913043,45.2173913043478,53.0434782608696,37.3913043478261,37.3913043478261,33.4782608695652,45.2173913043478,41.304347826087,29.5652173913043,13.9130434782609,25.6521739130435,41.304347826087,29.5652173913043,37.3913043478261,13.9130434782609,21.7391304347826,33.4782608695652,21.7391304347826,37.3913043478261,25.6521739130435,21.7391304347826,21.7391304347826,29.5652173913043,41.304347826087,10,37.3913043478261,53.0434782608696,41.304347826087,33.4782608695652,53.0434782608696,41.304347826087,60.8695652173913,76.5217391304348,80.4347826086957,76.5217391304348,60.8695652173913,76.5217391304348,76.5217391304348,76.5217391304348,72.6086956521739,64.7826086956522,84.3478260869565,68.695652173913,64.7826086956522,64.7826086956522,56.9565217391304,68.695652173913,68.695652173913,68.695652173913,68.695652173913,60.8695652173913,72.6086956521739,60.8695652173913,60.8695652173913,80.4347826086957,68.695652173913,60.8695652173913,80.4347826086957,68.695652173913,64.7826086956522,100,72.6086956521739,64.7826086956522,84.3478260869565,76.5217391304348,96.0869565217391,76.5217391304348,84.3478260869565,68.695652173913,92.1739130434783,64.7826086956522,56.9565217391304,68.695652173913,72.6086956521739,80.4347826086957,84.3478260869565,76.5217391304348,80.4347826086957,88.2608695652174,80.4347826086957,84.3478260869565,56.9565217391304,80.4347826086957,64.7826086956522,64.7826086956522,60.8695652173913,64.7826086956522,56.9565217391304,60.8695652173913,64.7826086956522,80.4347826086957,41.304347826087,64.7826086956522,53.0434782608696,56.9565217391304,64.7826086956522,53.0434782608696,60.8695652173913,56.9565217391304,56.9565217391304,64.7826086956522,53.0434782608696,56.9565217391304,49.1304347826087,41.304347826087,56.9565217391304,76.5217391304348,49.1304347826087,49.1304347826087,45.2173913043478,60.8695652173913,53.0434782608696,45.2173913043478,60.8695652173913,80.4347826086957,60.8695652173913,68.695652173913,49.1304347826087,76.5217391304348,64.7826086956522,68.695652173913,53.0434782608696,60.8695652173913,45.2173913043478,53.0434782608696,53.0434782608696,53.0434782608696,56.9565217391304,56.9565217391304,45.2173913043478,56.9565217391304],"sizemode":"area","line":{"color":"rgba(252,141,98,1)"}},"textfont":{"color":"rgba(252,141,98,1)","size":[68.695652173913,33.4782608695652,49.1304347826087,60.8695652173913,53.0434782608696,60.8695652173913,53.0434782608696,72.6086956521739,56.9565217391304,72.6086956521739,60.8695652173913,56.9565217391304,76.5217391304348,64.7826086956522,72.6086956521739,60.8695652173913,60.8695652173913,64.7826086956522,49.1304347826087,49.1304347826087,45.2173913043478,56.9565217391304,49.1304347826087,49.1304347826087,64.7826086956522,45.2173913043478,49.1304347826087,45.2173913043478,45.2173913043478,41.304347826087,37.3913043478261,49.1304347826087,53.0434782608696,41.304347826087,49.1304347826087,53.0434782608696,53.0434782608696,33.4782608695652,37.3913043478261,29.5652173913043,45.2173913043478,45.2173913043478,37.3913043478261,37.3913043478261,29.5652173913043,45.2173913043478,53.0434782608696,37.3913043478261,37.3913043478261,33.4782608695652,45.2173913043478,41.304347826087,29.5652173913043,13.9130434782609,25.6521739130435,41.304347826087,29.5652173913043,37.3913043478261,13.9130434782609,21.7391304347826,33.4782608695652,21.7391304347826,37.3913043478261,25.6521739130435,21.7391304347826,21.7391304347826,29.5652173913043,41.304347826087,10,37.3913043478261,53.0434782608696,41.304347826087,33.4782608695652,53.0434782608696,41.304347826087,60.8695652173913,76.5217391304348,80.4347826086957,76.5217391304348,60.8695652173913,76.5217391304348,76.5217391304348,76.5217391304348,72.6086956521739,64.7826086956522,84.3478260869565,68.695652173913,64.7826086956522,64.7826086956522,56.9565217391304,68.695652173913,68.695652173913,68.695652173913,68.695652173913,60.8695652173913,72.6086956521739,60.8695652173913,60.8695652173913,80.4347826086957,68.695652173913,60.8695652173913,80.4347826086957,68.695652173913,64.7826086956522,100,72.6086956521739,64.7826086956522,84.3478260869565,76.5217391304348,96.0869565217391,76.5217391304348,84.3478260869565,68.695652173913,92.1739130434783,64.7826086956522,56.9565217391304,68.695652173913,72.6086956521739,80.4347826086957,84.3478260869565,76.5217391304348,80.4347826086957,88.2608695652174,80.4347826086957,84.3478260869565,56.9565217391304,80.4347826086957,64.7826086956522,64.7826086956522,60.8695652173913,64.7826086956522,56.9565217391304,60.8695652173913,64.7826086956522,80.4347826086957,41.304347826087,64.7826086956522,53.0434782608696,56.9565217391304,64.7826086956522,53.0434782608696,60.8695652173913,56.9565217391304,56.9565217391304,64.7826086956522,53.0434782608696,56.9565217391304,49.1304347826087,41.304347826087,56.9565217391304,76.5217391304348,49.1304347826087,49.1304347826087,45.2173913043478,60.8695652173913,53.0434782608696,45.2173913043478,60.8695652173913,80.4347826086957,60.8695652173913,68.695652173913,49.1304347826087,76.5217391304348,64.7826086956522,68.695652173913,53.0434782608696,60.8695652173913,45.2173913043478,53.0434782608696,53.0434782608696,53.0434782608696,56.9565217391304,56.9565217391304,45.2173913043478,56.9565217391304]},"error_y":{"color":"rgba(252,141,98,1)","width":[]},"error_x":{"color":"rgba(252,141,98,1)","width":[]},"line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
<p><strong>Species richness variation along stands</strong></p>
<div id="htmlwidget-9a0bfe95c1ba66273bc6" style="width:624px;height:384px;" class="plotly html-widget"></div>
<script type="application/json" data-for="htmlwidget-9a0bfe95c1ba66273bc6">{"x":{"visdat":{"324d42d133d7":["function () ","plotlyVisDat"]},"cur_data":"324d42d133d7","attrs":{"324d42d133d7":{"y":{},"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"color":{},"symbol":"stand","alpha_stroke":1,"sizes":[10,100],"spans":[1,20],"type":"box"}},"layout":{"margin":{"b":40,"l":60,"t":25,"r":10},"title":"","xaxis":{"domain":[0,1],"automargin":true,"title":"Stand","showgrid":false},"yaxis":{"domain":[0,1],"automargin":true,"title":"Species richness","showgrid":false},"hovermode":"closest","showlegend":true},"source":"A","config":{"modeBarButtonsToAdd":["hoverclosest","hovercompare"],"showSendToCloud":false},"data":[{"fillcolor":"rgba(102,194,165,0.5)","y":[21,12,16,19,17,19,17,22,18,22,19,18,23,20,22,19,19,20,16,16,15,18,16,16,20],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"1<br />stand","marker":{"color":"rgba(102,194,165,1)","symbol":"circle","line":{"color":"rgba(102,194,165,1)"}},"mode":"+markers","line":{"color":"rgba(102,194,165,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(252,141,98,0.5)","y":[15,16,15,15,14,13,16,17,14,16,17,17,12,13,11,15,15,13,13,11,15,17,13,13,12],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"3<br />stand","marker":{"color":"rgba(252,141,98,1)","symbol":"circle","line":{"color":"rgba(252,141,98,1)"}},"mode":"+markers","line":{"color":"rgba(252,141,98,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(141,160,203,0.5)","y":[15,14,11,7,10,14,11,13,7,9,12,9,13,10,9,9,11,14,6,13,17,14,12,17,14],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"4<br />stand","marker":{"color":"rgba(141,160,203,1)","symbol":"circle","line":{"color":"rgba(141,160,203,1)"}},"mode":"+markers","line":{"color":"rgba(141,160,203,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(231,138,195,0.5)","y":[19,23,24,23,19,23,23,23,22,20,25,21,20,20,18,21,21,21,21,19,22,19,19,24,21],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"5<br />stand","marker":{"color":"rgba(231,138,195,1)","symbol":"circle","line":{"color":"rgba(231,138,195,1)"}},"mode":"+markers","line":{"color":"rgba(231,138,195,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(166,216,84,0.5)","y":[19,24,21,20,29,22,20,25,23,28,23,25,21,27,20,18,21,22,24,25,23,24,26,24,25],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"6<br />stand","marker":{"color":"rgba(166,216,84,1)","symbol":"circle","line":{"color":"rgba(166,216,84,1)"}},"mode":"+markers","line":{"color":"rgba(166,216,84,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(255,217,47,0.5)","y":[18,24,20,20,19,20,18,19,20,24,14,20,17,18,20,17,19,18,18,20,17,18,16,14,18],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"7<br />stand","marker":{"color":"rgba(255,217,47,1)","symbol":"circle","line":{"color":"rgba(255,217,47,1)"}},"mode":"+markers","line":{"color":"rgba(255,217,47,1)"},"xaxis":"x","yaxis":"y","frame":null},{"fillcolor":"rgba(229,196,148,0.5)","y":[23,16,16,15,19,17,15,19,24,19,21,16,23,20,21,17,19,15,17,17,17,18,18,15,18],"boxpoints":"all","jitter":0.4,"pointpos":-1.8,"type":"box","name":"8<br />stand","marker":{"color":"rgba(229,196,148,1)","symbol":"circle","line":{"color":"rgba(229,196,148,1)"}},"mode":"+markers","line":{"color":"rgba(229,196,148,1)"},"xaxis":"x","yaxis":"y","frame":null}],"highlight":{"on":"plotly_click","persistent":false,"dynamic":false,"selectize":false,"opacityDim":0.2,"selected":{"opacity":1},"debounce":0},"shinyEvents":["plotly_hover","plotly_click","plotly_selected","plotly_relayout","plotly_brushed","plotly_brushing","plotly_clickannotation","plotly_doubleclick","plotly_deselect","plotly_afterplot","plotly_sunburstclick"],"base_url":"https://plot.ly"},"evals":[],"jsHooks":[]}</script>
<p><strong>Counts of the number of species frequencies in each abundance
class</strong></p>
<p>We already know the patterns among stands, soil temperature, and
interaction. But, what do continuous variables (species richness and
soil temperature) tell us regarding their frequency distributions?</p>
<p>Species richness clearly follows a normal distribution.</p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-6-1.png" width="624" /></p>
<p><strong>Counts of the number of soil temperature frequencies in each
abundance class</strong></p>
<p>Soil temperature not necessarily follows a normal distribution, but
it seems like can assume it.</p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-7-1.png" width="624" /></p>
</div>
<div id="section-model-codification-gets-started"
class="section level3">
<h3><strong>Model codification: Get’s started!</strong></h3>
<p>In order to understand how soil temperature in Celsius and stand (x =
independent variable) can affect biodiversity we can create five
different models containing Species richness as response variable (y =
dependent variable).</p>
<pre><code># Species richness as function of soil temperature (C) alone
M1 <- lm(SR ~ temp_C,data = SR_SoilTemp)
# Species richness as function of stand alone
M2 <-lm(SR ~ stand,data = SR_SoilTemp)
# Species richness as function of soil temperature (C) plus stand, and soil temperature-stand interaction
M3 <- lm(SR ~ temp_C*stand,data = SR_SoilTemp)
# Species richness as function of soil temperature (C) and stand
M4 <- lm(SR ~ temp_C+stand,data = SR_SoilTemp)
# Species richness as function of soil temperature-stand interaction alone
M5 <- lm(SR ~ temp_C:stand,data = SR_SoilTemp)</code></pre>
</div>
<div id="section-model-selection" class="section level3">
<h3><strong>Model selection</strong></h3>
<p>Regarding patterns associated to species richness in function of soil
temperature and stand, can we use these results to formulate our
ecological conclusions? Does putting together both soil temperature and
stand can reveal a pattern hidden by modeling both variable
independently? We can use AICc and R squared approach to select the best
model. Here we can see that model M2 and M4 are the best options
following a lm approach with fixed effects. However, M4 model presented
a reduced R squared. M2 model, only species richness as function of
stand, presented a lower AIC and a higher R squared.</p>
<div data-pagedtable="false">
<script data-pagedtable-source type="application/json">
{"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["R2_adjusted"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["r2"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["df"],"name":[3],"type":["int"],"align":["right"]},{"label":["logLik"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["AICc"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["delta"],"name":[6],"type":["dbl"],"align":["right"]}],"data":[{"1":"0.02338876","2":"0.02900147","3":"9","4":"-401.3830","5":"821.8570","6":"0.000000","_rn_":"M4"},{"1":"0.67959718","2":"0.69064555","3":"8","4":"-403.1450","5":"823.1575","6":"1.300477","_rn_":"M2"},{"1":"0.68450887","2":"0.70808004","3":"15","4":"-398.0693","5":"829.1575","6":"7.300465","_rn_":"M3"},{"1":"0.68410416","2":"0.69681262","3":"9","4":"-407.4184","5":"833.9278","6":"12.070786","_rn_":"M5"},{"1":"0.66154591","2":"0.67516188","3":"3","4":"-503.2308","5":"1012.6019","6":"190.744876","_rn_":"M1"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
<p>df is the degree of freedom, logLik is the loglikelihood, and delta
is the AICc difference with the lowest value</p>
<p>Let’s use the M2 model use to see how it works species richness in
function of stands. We can identify M2 models as the best one according
to its lowest AICc and R squared. But, before doing an analysis of
variance and a post-hoc mean comparisons we must check the linear
regression model assumptions.</p>
<pre><code># Species richness as function of stand
M2 <-lm(SR ~ stand,data = SR_SoilTemp) </code></pre>
</details>
</div>
<div id="section-model-validation" class="section level3">
<h3><strong>Model validation</strong></h3>
<p><strong>Homogeneity of the variance</strong></p>
<p>Plot predicted values vs residual values</p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-10-1.png" width="624" /></p>
<p>Homogeneity of variance test</p>
<pre><code>##
## Bartlett test of homogeneity of variances
##
## data: SR by stand
## Bartlett's K-squared = 8.8994, df = 6, p-value = 0.1793</code></pre>
<p>There is a homogeneous dispersion of the residuals regarding the
graphic and the homogeneity of variance test(p-value = 0.1793). <em>The
assumption is respected!</em></p>
<p><strong>Independence of the model residuals</strong></p>
<p>Check the independence of the model residuals with stands</p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-12-1.png" width="624" /></p>
<p>Homogeneous dispersion of the residuals around 0 and no pattern of
residuals depending on the variable. <em>The assumption is
respected!!</em></p>
<p><strong>Normality of the model residuals</strong></p>
<p>Histogram of model residuals
<img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-13-1.png" width="624" /></p>
<p>Shapiro test to check residuals normality</p>
<pre><code>##
## Shapiro-Wilk normality test
##
## data: ANOVA_M2$residuals
## W = 0.98975, p-value = 0.2401</code></pre>
<p>The residuals follow a normal distribution regarding the histogram
and the Shapiro test(p-value = 0.2401). <em>The assumption is respected
!!!</em></p>
</div>
<div id="section-model-interpretation-and-visualization"
class="section level3">
<h3><strong>Model interpretation and visualization</strong></h3>
<p><strong>Species richness as a function of stand</strong></p>
<p>Once we have corroborated the linear regression model assumption we
can continue with model interpretation and visualization. There are
significant differences among stands (p < 2.2e-16). Stands 3 and 4
are associated with less species richness than stands 5 and 6.</p>
<pre><code>## Df Sum Sq Mean Sq F value Pr(>F)
## stand 6 2292 382.1 62.51 <2e-16 ***
## Residuals 168 1027 6.1
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1</code></pre>
<pre><code>## Warning in boxplot.default(split(mf[[response]], mf[-response], drop = drop, :
## NAs introduced by coercion</code></pre>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-16-1.png" width="624" /></p>
<p>Different colours in the stands mean statistical differences.</p>
</div>
</div>
<div id="section-non-linear-model-relationship-in-ecological-data"
class="section level2" data-progressive="TRUE">
<h2><strong>Non-linear model relationship in ecological
data</strong></h2>
<p>Run the following code. Then observe the AIC table and the graphic
visualization.</p>
<div class="tutorial-exercise" data-label="Linear_not_linear"
data-completion="1" data-diagnostics="1" data-startover="1"
data-lines="25">
<pre class="text"><code># Data
x <- c(1.1,1.2,0.7,3.4,3.6,2.7,5.2,5.3,4.7,7.3,7.5,6.7,9.4,9.1,8.9,11.3,10.7,11)
y_response <- c(0.8,0.7,1.2,9.1,8.7,9.3,25.3,25.8,24.2,50,48.5,51,81.1,80.8,81.2,121.5,121,120.7)
Linear_not_linear <- data.frame(x,y_response)
# Linear model or not?
library(mgcv)
linear_model <- gam(y_response ~ x, data = Linear_not_linear)
smooth_model <- gam(y_response ~ s(x), data = Linear_not_linear)
AIC(linear_model, smooth_model)
# Visualization
library(ggplot2)
p1<-ggplot(Linear_not_linear, aes(x = x, y = y_response )) +
geom_point() +
geom_line(colour = "red", size = 1.2,
aes(y = fitted(linear_model))) +
xlab("x") +
ylab("y") +
labs(title = "Linear model or not?")+
geom_line(colour = "blue", size = 1.2,
aes(y = fitted(smooth_model))) +
theme_bw()
p1</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<details>
<summary>
<strong>Linear model or not?</strong>
</summary>
<p>
You can see that the AIC and the trend of the smooth GAM justify that
adding a smoothing function improves model performance. Non linearity is
then supported by these data.
<p>
</div>
<div id="section-exercises" class="section level2">
<h2><strong>Exercises</strong></h2>
<p><strong>Species richness as a function of soil temperature
(°C)</strong></p>
<p>Run the following code and answer the question below. Here, we use
model one (M1) corresponding to species richness as a function of soil
temperature (C) to verify if there is any relationship between species
richness and soil temperature alone. We will consider that model
assumption are respected.</p>
<div class="tutorial-exercise" data-label="M1_plot" data-completion="1"
data-diagnostics="1" data-startover="1" data-lines="36">
<pre class="text"><code># Importing data
Hondo_VascularCover_2010_CLEAN<-read.csv("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_VascularCover_2010_CLEAN.csv", sep=";")
Hondo_SoilTemp_2010_CLEAN<- read.csv("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_SoilTemp_2010_CLEAN.csv", sep=";")
# Merging data
SR_SoilTemp <- data.frame(stand=as.factor(Hondo_SoilTemp_2010_CLEAN$stand),
SR=Hondo_VascularCover_2010_CLEAN$SR,
temp_C=Hondo_SoilTemp_2010_CLEAN$temp_C)
# Species richness as function of soil temperature (C)
M1 <- lm(SR ~ temp_C,data = SR_SoilTemp)
# Residuals and coefficients of the model
(summ_M1 <- summary(M1)) #
# Simplified ggplot theme
library(ggplot2)
fig <- theme_bw() +
theme(panel.grid.minor=element_blank(),
panel.grid.major=element_blank(),
panel.background=element_blank()) +
theme(strip.background=element_blank(),
strip.text.y = element_text()) +
theme(legend.background=element_blank()) +
theme(legend.key=element_blank()) +
theme(panel.border = element_rect(colour="black", fill=NA))
# Plot
plot <- ggplot(aes(temp_C, SR), data = SR_SoilTemp)
Plot_AllData <- plot + geom_point() +
xlab("Soil temperature (C)") +
ylab("Species richness") +
labs(title = "All data") + fig
# Add regression lines with the intercepts specific to each stand
Plot_AllData +
geom_abline(intercept = 23.8756 ,
slope = -0.3346, col = "coral2")</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p>Check the graphic, then the p-value of soil temperature (temp_C).
Respond to the following question:</p>
<div class="panel-heading tutorial-quiz-title"><span data-i18n="text.quiz">Quiz</span></div>
<div class="panel panel-default tutorial-question-container">
<div data-label="quizM1-1" class="tutorial-question panel-body">
<div id="quizM1-1-answer_container" class="shiny-html-output"></div>
<div id="quizM1-1-message_container" class="shiny-html-output"></div>
<div id="quizM1-1-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
<p>Now, let’s explore our real species richness and soil temperature
data relationship. Follow the next steps:</p>
<ol style="list-style-type: decimal">
<li>Code by yourself: Use and adapt R code to check linearity.</li>
<li>Use code from Hint: Click on Hint to review and paste the code. The
run the code.</li>
</ol>
<div class="tutorial-exercise" data-label="print-linearityTest"
data-completion="1" data-diagnostics="1" data-startover="1"
data-lines="25">
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<div class="tutorial-exercise-support"
data-label="print-linearityTest-hint" data-completion="1"
data-diagnostics="1" data-startover="1" data-lines="0">
<pre class="text"><code># Data
Hondo_VascularCover_2010_CLEAN<-read.csv("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_VascularCover_2010_CLEAN.csv", sep=";")
Hondo_SoilTemp_2010_CLEAN<- read.csv("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_SoilTemp_2010_CLEAN.csv", sep=";")
SR_SoilTemp <- data.frame(stand=as.factor(Hondo_SoilTemp_2010_CLEAN$stand),
SR=Hondo_VascularCover_2010_CLEAN$SR,
temp_C=Hondo_SoilTemp_2010_CLEAN$temp_C)
# Linear model or not?
library(mgcv)
linear_model <- gam(SR ~ temp_C, data = SR_SoilTemp)
smooth_model <- gam(SR ~ s(temp_C), data = SR_SoilTemp)
AIC(linear_model, smooth_model)
# Visualization
library(ggplot2)
Non_linear<-ggplot(SR_SoilTemp, aes(x = temp_C, y = SR )) +
geom_point() +
xlab("Soil temperature (C)") +
ylab("Species richness") +
labs(title = "Smooth model curve: Linear model or not?")+
geom_line(colour = "blue", size = 1.2,
aes(y = fitted(smooth_model))) +
theme_bw()
Non_linear
Linear<-ggplot(SR_SoilTemp, aes(x = temp_C, y = SR )) +
geom_point() +
geom_line(colour = "red", size = 1.2,
aes(y = fitted(linear_model))) +
xlab("Soil temperature (C)") +
ylab("Species richness") +
labs(title = "Linear model line:Linear model or not?")+
theme_bw()
Linear</code></pre>
</div>
<div class="panel-heading tutorial-quiz-title"><span data-i18n="text.quiz">Quiz</span></div>
<div class="panel panel-default tutorial-question-container">
<div data-label="quizLinearity-1" class="tutorial-question panel-body">
<div id="quizLinearity-1-answer_container" class="shiny-html-output"></div>
<div id="quizLinearity-1-message_container" class="shiny-html-output"></div>
<div id="quizLinearity-1-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
<p><strong>Interaction model</strong></p>
<p>Situation: we are interested to model the species richness of Hondo
as a function of temperature (this is our main predictor of interest)
but we don’t know if we need to consider the stand as another important
variable in the model. Observe the following graphics (M1, M3 and M4
model) and then the r squared and AICc into the summary table. Respond
to the questions below.</p>
<p><strong>Species richness as a function of soil temperature (°C) plus
stand, and soil temperature-stand interaction</strong></p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-17-1.png" width="624" /></p>
<p><strong>Species richness as a function of soil temperature (°C) plus
stand, and soil temperature-stand interaction</strong></p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-18-1.png" width="624" /></p>
<p><strong>Species richness as a function of soil temperature (°C) and
stand</strong></p>
<p><img src="Biodiversity_Alberta_files/figure-html/unnamed-chunk-19-1.png" width="624" /></p>
<div data-pagedtable="false">
<script data-pagedtable-source type="application/json">
{"columns":[{"label":[""],"name":["_rn_"],"type":[""],"align":["left"]},{"label":["R2_adjusted"],"name":[1],"type":["dbl"],"align":["right"]},{"label":["r2"],"name":[2],"type":["dbl"],"align":["right"]},{"label":["df"],"name":[3],"type":["int"],"align":["right"]},{"label":["logLik"],"name":[4],"type":["dbl"],"align":["right"]},{"label":["AICc"],"name":[5],"type":["dbl"],"align":["right"]},{"label":["delta"],"name":[6],"type":["dbl"],"align":["right"]}],"data":[{"1":"0.02338876","2":"0.02900147","3":"9","4":"-401.3830","5":"821.8570","6":"0.000000","_rn_":"M4"},{"1":"0.68450887","2":"0.70808004","3":"15","4":"-398.0693","5":"829.1575","6":"7.300465","_rn_":"M3"},{"1":"0.68410416","2":"0.69681262","3":"3","4":"-503.2308","5":"1012.6019","6":"190.744876","_rn_":"M1"}],"options":{"columns":{"min":{},"max":[10]},"rows":{"min":[10],"max":[10]},"pages":{}}}
</script>
</div>
<p>df is the degree of freedom, logLik is the loglikelihood, and delta
is the AICc difference with the lowest value</p>
<div class="panel-heading tutorial-quiz-title"><span data-i18n="text.quiz">Quiz</span></div>
<div class="panel panel-default tutorial-question-container">
<div data-label="quizInteraction-1" class="tutorial-question panel-body">
<div id="quizInteraction-1-answer_container" class="shiny-html-output"></div>
<div id="quizInteraction-1-message_container" class="shiny-html-output"></div>
<div id="quizInteraction-1-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
<div id="section-reproducibility" class="section level3">
<h3><strong>Reproducibility</strong></h3>
<p>The graphics and results presented in this tutorial were obtained
using historical soil temperature data, and vascular diversity datasets
from Hondo stands. Data is available at [<a
href="https://dataverse.scholarsportal.info/dataset.xhtml?persistentId=doi:10.5683/SP3/PZCAVE"
class="uri">https://dataverse.scholarsportal.info/dataset.xhtml?persistentId=doi:10.5683/SP3/PZCAVE</a>].
We imported the original datasets from the Import dataset in R
Studio.</p>
<pre><code>Hondo_VascularCover_1980_2015 # Historical
str(Hondo_VascularCover_1980_2015)
Hondo_SoilTemp_1980_2010 # Historical soil temperature
str(Hondo_SoilTemp_1980_2010)</code></pre>
<p><strong>Dataset manipulation</strong></p>
<p>1.Generate a subset of data considering only 2010 data to simplify
the statistical analyses. It is important to focus on the heart of
species richness ecological concept connected to space and
environment.</p>
<pre><code>Hondo_VascularCover_2010 <- subset(Hondo_VascularCover_1980_2015,year== "2010" ) # Selecting from one category in rows
Hondo_SoilTemp_2010 <- subset(Hondo_SoilTemp_1980_2010,year== "2010" )</code></pre>
<ol start="2" style="list-style-type: decimal">
<li>Save the 2010 subsets data in the computer to clean it and make it
proper to work in R.</li>
</ol>
<pre><code>write.csv(x=Hondo_VascularCover_2010,file="Hondo_VascularCover_2010.csv", row.names=FALSE) # Export data in csv format
write.csv(x=Hondo_SoilTemp_2010,file="Hondo_SoilTemp_2010.csv", row.names=FALSE) </code></pre>
<ol start="3" style="list-style-type: decimal">
<li><p>Open the 2010 subsets in excel and order both of them by stand
and quad, then corroborate the perfect correspondence in order.</p></li>
<li><p>Generate a new data frame summarizing stand, quadrant, soil
temperature and species richness. You can see here that quadrants and
stands were merged adequately.</p></li>
</ol>
</div>
</div>
<div id="section-dendrochonology-what-it-is" class="section level2"
data-progressive="TRUE">
<h2><strong>Dendrochonology: what it is?</strong></h2>
<p>Tree Stories: How Tree Rings Reveal Extreme Weather Cycles? <em>Video
from Brigham Young University, Utah</em></p>
<div class="vembedr" align="center">
<div>
<iframe src="https://www.youtube.com/embed/xmZO7aRgcW4" width="533" height="300" frameborder="0" allowfullscreen="" data-external="1"></iframe>
</div>
</div>
<p>An interesting concept in biology, and more in forestry, is the ring
dynamics of trees over time. Dendrochronology is the dating and study of
annual rings in trees (see <a
href="https://ltrr.arizona.edu/about/treerings"
class="uri">https://ltrr.arizona.edu/about/treerings</a>). Dating and
studying annual rings allow us to do inferences in other tree fields of
study, for example, linking dendrochronology with the weather. Here,
Dendroclimatology studies and uses the growth ring patterns to
reconstruct past variations in climate (Fritts. 1987). Since
well-defined annual-growth rings can be observed in the wood (rings)
from many species of temperate forest trees throughout the world, in
certain circumstances, these growth rings contain useful information
about varying environmental conditions affecting their growth like
temperature changes and humidity as well as tree features (age and
size), depending on the species and latitude for what other data
analysis (climate data) should be included (Tumajer, J., & Lehejček,
J. 2019).</p>
</div>
<div id="section-tree-ring-analysis-over-time" class="section level2">
<h2><strong>Tree ring analysis over time</strong></h2>
<p>Let’s plot some graphics. We can plot the average ring width (mm) in
axe y in the function of time (year) in axe x (see red line). But, we
can also plot the average ring width (mm) in axe y as a function of time
(year) in axe x, simultaneously considering the stands (see gray lines).
Do you have some ideas about what these trends might be telling us?</p>
<p><strong>Rings data from Hondo-Slave Lake (hereafter, Hondo) region of
Alberta</strong></p>
<div class="tutorial-exercise" data-label="AOS_plot" data-completion="1"
data-diagnostics="1" data-startover="1" data-lines="37">
<pre class="text"><code># Libraries
library(tidyverse)
library(readr)
library(dplyr)
library(ggplot2)
# AOS sites
# for BP, JS, LF, ML, OI, SA, WO, WY stands
# Files
aos_files <- c("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20BP.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20JS.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20LF.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20ML.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20OI.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20SA.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20WO.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/AOS_Dendrochronology_1983%20-%20WY.csv"
)
# Visualization
aos_dt <-
do.call(rbind,
lapply(aos_files, read.csv))
summary(aos_dt)
table(aos_dt$stand)
aos_dt %>% group_by(year, stand) %>%
summarise(avg_ring_width_mm = mean(ring_width_mm),
n = n()) %>%
ggplot(aes(x = year, y = avg_ring_width_mm)) +
geom_point(data = aos_dt, aes(x = year, y = ring_width_mm), shape = 21,
size= 2, color = 'gray50', alpha = .2) + geom_smooth(aes(group = stand), alpha = .2, color = 'gray40') +
theme_bw() +
facet_grid(~stand) +
geom_smooth(data = aos_dt %>% select(-stand), aes(x = year, y = ring_width_mm),
color = 'red', linetype = 'dashed')</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
<p><strong>Rings data from Athabasca Oil Sands (hereafter, AOS) region
in northeastern Alberta</strong></p>
<div class="tutorial-exercise" data-label="Hondo_plot"
data-completion="1" data-diagnostics="1" data-startover="1"
data-lines="33">
<pre class="text"><code># Libraries
library(tidyverse)
library(readr)
library(dplyr)
library(ggplot2)
## same for HONDO
#n=1, 2, 3 stands
# Files
hondo_files <- c("https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_Dendrochronology_1983%20-%20STAND%201.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_Dendrochronology_1983%20-%20STAND%202.csv",
"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_Dendrochronology_1983%20-%20STAND%203.csv"
)
# Visualization
hondo_dt <-
do.call(rbind,
lapply(hondo_files, read.csv)) %>%
mutate(stand = factor(stand))
hondo_dt %>% group_by(year, stand) %>%
summarise(avg_ring_width_mm = mean(ring_width_mm),
n = n()) %>%
ggplot(aes(x = year, y = avg_ring_width_mm)) +
geom_point(data = hondo_dt, aes(x = year, y = ring_width_mm, group = stand), shape = 21,
size= 2, color = 'gray50', alpha = .2) +
geom_smooth(aes(group = stand), alpha = .2, color = 'gray40') +
theme_bw() +
facet_grid(~stand) +
geom_smooth(data = hondo_dt %>% select(-stand), aes(x = year, y = ring_width_mm),
color = 'red', linetype = 'dashed')</code></pre>
<script type="application/json" data-ui-opts="1">{"engine":"r","has_checker":false,"caption":"<span data-i18n=\"text.enginecap\" data-i18n-opts=\"{"engine":"R"}\">R Code<\/span>"}</script>
</div>
</div>
<div id="section-exercises-1" class="section level2">
<h2><strong>Exercises</strong></h2>
<details>
<summary>
<strong>What can we deduce from the graphics?</strong> (Open responses)
</summary>
<p>
<p>BINGO!!!:</p>
<pre><code> 1. Tree ring width decreases over time, and patterns change following an oscillating behaviour, suggesting that external (temperature, humidity) and internal (age, latitude, species) factors affect tree growth.
2. It seems that stands follow different patterns, perhaps they have a different composition, or why not, they can be more or less diverse in vascular species affecting overall tree growth.
</code></pre>
<p>As you can see, the information observed in the graphics can bring us
some insights about what is going on with ring tree dynamics.</p>
</details>
<details>
<summary>
<strong>Multiple choice questions</strong>
</summary>
<p>
<div class="panel-heading tutorial-quiz-title"><span data-i18n="text.quiz">Quiz</span></div>
<div class="panel panel-default tutorial-question-container">
<div data-label="quiz1-1" class="tutorial-question panel-body">
<div id="quiz1-1-answer_container" class="shiny-html-output"></div>
<div id="quiz1-1-message_container" class="shiny-html-output"></div>
<div id="quiz1-1-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
<div class="panel panel-default tutorial-question-container">
<div data-label="quiz1-2" class="tutorial-question panel-body">
<div id="quiz1-2-answer_container" class="shiny-html-output"></div>
<div id="quiz1-2-message_container" class="shiny-html-output"></div>
<div id="quiz1-2-action_button_container" class="shiny-html-output"></div>
<script>if (Tutorial.triggerMathJax) Tutorial.triggerMathJax()</script>
</div>
</div>
</details>
</div>
<div id="section-references" class="section level2">
<h2><strong>References</strong></h2>
<p>Hesketh, A., Loesberg, J., Bledsoe, E., Karst, J., & Macdonald,
E. (2021). Seasonal and annual dynamics of western Canadian boreal
forest plant communities: A legacy dataset spanning four decades [Data
set]. Scholars Portal Dataverse. <a
href="https://doi.org/10.5683/SP3/PZCAVE"
class="uri">https://doi.org/10.5683/SP3/PZCAVE</a></p>
<p>Canadian Endangered Species Conservation Council(CESCC). 2010. Wild
Species 2010: The general status of Species in Canada.</p>
<p>Jin, Y., and Qian, H. 2019. V.PhyloMaker: an R package that can
generate very large phylogenies for vascular plants. Ecography, 42:
1353: 1359.</p>
<p>Packer, J.G., and Gould, A.J. 2017. Vascular plants of Alberta, part
1: Ferns, Fern Allies, Gymnosperms, and monocots. University of Calgary
Press. 281 pages.</p>
<p>Earle, C.J. 2021.The Gymnossperm Database. Consulted on April 7,
2022:[<a href="https://www.conifers.org/zz/gymnosperms.php"
class="uri">https://www.conifers.org/zz/gymnosperms.php</a>]. Go Botany
(3.7). 2022. Native Plant Trust. Consulted on April 7, 2022: [<a
href="https://gobotany.nativeplanttrust.org"
class="uri">https://gobotany.nativeplanttrust.org</a>]</p>
<p>Fritts, H. C. (1987). TREE-RING ANALYSISTree-ring analysis. In
Climatology (pp. 858–875). Springer US. <a
href="https://doi.org/10.1007/0-387-30749-4_182"
class="uri">https://doi.org/10.1007/0-387-30749-4_182</a></p>
<p>Tumajer, J., & Lehejček, J. (2019). Boreal tree-rings are
influenced by temperature up to two years prior to their formation: A
trade-off between growth and reproduction? Environmental Research
Letters, 14(12), 124024. <a
href="https://doi.org/10.1088/1748-9326/ab5134"
class="uri">https://doi.org/10.1088/1748-9326/ab5134</a></p>
<p>NOAA. . Picture Climate: How Can We Learn from Tree Rings? | National
Centers for Environmental Information (NCEI) formerly known as National
Climatic Data Center (NCDC). (n.d.). Retrieved 8 April 2022, from <a
href="https://www.ncdc.noaa.gov/news/picture-climate-how-can-we-learn-tree-rings"
class="uri">https://www.ncdc.noaa.gov/news/picture-climate-how-can-we-learn-tree-rings</a></p>
<p>Rivet, A., Payette, S., Berteaux, D., & Girard, F. (2017). Pines
and porcupines: A tree-ring analysis of browsing and dynamics of an
overmature pine forest. Canadian Journal of Forest Research, 47,
257–268. <a href="https://doi.org/10.1139/cjfr-2016-0214"
class="uri">https://doi.org/10.1139/cjfr-2016-0214</a></p>
</div>
<div id="section-glossary" class="section level2">
<h2><strong>Glossary</strong></h2>
</div>
<div id="section-français" class="section level2">
<h2><strong>Français</strong></h2>
<p>Version en français disponible sur <a
href="https://rtrejo.shinyapps.io/Biodiversite_Arbres_Alberta"
class="uri">https://rtrejo.shinyapps.io/Biodiversite_Arbres_Alberta</a>
<script type="application/shiny-prerendered" data-context="server">
learnr:::register_http_handlers(session, metadata = NULL)
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::prepare_tutorial_state(session)
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::i18n_observe_tutorial_language(input, session)
</script>
<script type="application/shiny-prerendered" data-context="server">
session$onSessionEnded(function() {
learnr:::event_trigger(session, "session_stop")
})
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-Linear_not_linear-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-Linear_not_linear-code-editor`)), session)
output$`tutorial-exercise-Linear_not_linear-output` <- renderUI({
`tutorial-exercise-Linear_not_linear-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(label = "Linear_not_linear", global_setup = NULL,
setup = NULL, chunks = list(list(label = "Linear_not_linear",
code = "\n# Data\nx <- c(1.1,1.2,0.7,3.4,3.6,2.7,5.2,5.3,4.7,7.3,7.5,6.7,9.4,9.1,8.9,11.3,10.7,11)\ny_response <- c(0.8,0.7,1.2,9.1,8.7,9.3,25.3,25.8,24.2,50,48.5,51,81.1,80.8,81.2,121.5,121,120.7)\nLinear_not_linear <- data.frame(x,y_response)\n\n# Linear model or not?\nlibrary(mgcv)\nlinear_model <- gam(y_response ~ x, data = Linear_not_linear)\nsmooth_model <- gam(y_response ~ s(x), data = Linear_not_linear)\nAIC(linear_model, smooth_model)\n\n# Visualization\nlibrary(ggplot2)\np1<-ggplot(Linear_not_linear, aes(x = x, y = y_response )) +\n geom_point() +\n geom_line(colour = \"red\", size = 1.2,\n aes(y = fitted(linear_model))) +\n xlab(\"x\") +\n ylab(\"y\") +\n labs(title = \"Linear model or not?\")+\n geom_line(colour = \"blue\", size = 1.2,\n aes(y = fitted(smooth_model))) +\n theme_bw()\n\np1\n",
opts = list(label = "\"Linear_not_linear\"", exercise = "TRUE",
exercise.lines = "25", message = "FALSE"), engine = "r")),
code_check = NULL, error_check = NULL, check = NULL, solution = NULL,
tests = NULL, options = list(eval = FALSE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "Biodiversity_Alberta_cache/html/", cache.vars = NULL,
cache.lazy = TRUE, dependson = NULL, autodep = FALSE,
cache.rebuild = FALSE, fig.keep = "high", fig.show = "asis",
fig.align = "default", fig.path = "Biodiversity_Alberta_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = FALSE,
message = FALSE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, label = "Linear_not_linear", exercise = TRUE,
exercise.lines = 25, code = c("", "# Data", "x <- c(1.1,1.2,0.7,3.4,3.6,2.7,5.2,5.3,4.7,7.3,7.5,6.7,9.4,9.1,8.9,11.3,10.7,11)",
"y_response <- c(0.8,0.7,1.2,9.1,8.7,9.3,25.3,25.8,24.2,50,48.5,51,81.1,80.8,81.2,121.5,121,120.7)",
"Linear_not_linear <- data.frame(x,y_response)", "",
"# Linear model or not?", "library(mgcv)", "linear_model <- gam(y_response ~ x, data = Linear_not_linear)",
"smooth_model <- gam(y_response ~ s(x), data = Linear_not_linear)",
"AIC(linear_model, smooth_model)", "", "# Visualization",
"library(ggplot2)", "p1<-ggplot(Linear_not_linear, aes(x = x, y = y_response )) +",
" geom_point() +", " geom_line(colour = \"red\", size = 1.2,",
" aes(y = fitted(linear_model))) +", " xlab(\"x\") +",
" ylab(\"y\") +", " labs(title = \"Linear model or not?\")+",
" geom_line(colour = \"blue\", size = 1.2,", " aes(y = fitted(smooth_model))) +",
" theme_bw()", "", "p1", ""), out.width.px = 624, out.height.px = 384,
params.src = "Linear_not_linear, exercise=TRUE, exercise.lines = 25, message=FALSE",
fig.num = 0, exercise.df_print = "paged", exercise.checker = "NULL"),
engine = "r", version = "3"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-M1_plot-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-M1_plot-code-editor`)), session)
output$`tutorial-exercise-M1_plot-output` <- renderUI({
`tutorial-exercise-M1_plot-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(label = "M1_plot", global_setup = NULL, setup = NULL,
chunks = list(list(label = "M1_plot", code = "# Importing data\nHondo_VascularCover_2010_CLEAN<-read.csv(\"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_VascularCover_2010_CLEAN.csv\", sep=\";\")\nHondo_SoilTemp_2010_CLEAN<- read.csv(\"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_SoilTemp_2010_CLEAN.csv\", sep=\";\")\n\n# Merging data\nSR_SoilTemp <- data.frame(stand=as.factor(Hondo_SoilTemp_2010_CLEAN$stand),\n SR=Hondo_VascularCover_2010_CLEAN$SR,\n temp_C=Hondo_SoilTemp_2010_CLEAN$temp_C)\n\n# Species richness as function of soil temperature (C)\nM1 <- lm(SR ~ temp_C,data = SR_SoilTemp) \n# Residuals and coefficients of the model\n(summ_M1 <- summary(M1)) #\n# Simplified ggplot theme\nlibrary(ggplot2)\nfig <- theme_bw() +\n theme(panel.grid.minor=element_blank(),\n panel.grid.major=element_blank(),\n panel.background=element_blank()) +\n theme(strip.background=element_blank(),\n strip.text.y = element_text()) +\n theme(legend.background=element_blank()) +\n theme(legend.key=element_blank()) +\n theme(panel.border = element_rect(colour=\"black\", fill=NA))\n# Plot\nplot <- ggplot(aes(temp_C, SR), data = SR_SoilTemp)\nPlot_AllData <- plot + geom_point() +\n xlab(\"Soil temperature (C)\") +\n ylab(\"Species richness\") +\n labs(title = \"All data\") + fig\n\n# Add regression lines with the intercepts specific to each stand\n\nPlot_AllData +\n geom_abline(intercept = 23.8756 ,\n slope = -0.3346, col = \"coral2\")\n\n",
opts = list(label = "\"M1_plot\"", exercise = "TRUE",
exercise.lines = "36", message = "FALSE"), engine = "r")),
code_check = NULL, error_check = NULL, check = NULL, solution = NULL,
tests = NULL, options = list(eval = FALSE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "Biodiversity_Alberta_cache/html/", cache.vars = NULL,
cache.lazy = TRUE, dependson = NULL, autodep = FALSE,
cache.rebuild = FALSE, fig.keep = "high", fig.show = "asis",
fig.align = "default", fig.path = "Biodiversity_Alberta_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = FALSE,
message = FALSE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, label = "M1_plot", exercise = TRUE,
exercise.lines = 36, code = c("# Importing data", "Hondo_VascularCover_2010_CLEAN<-read.csv(\"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_VascularCover_2010_CLEAN.csv\", sep=\";\")",
"Hondo_SoilTemp_2010_CLEAN<- read.csv(\"https://raw.githubusercontent.com/Living-Data-Tutorials/website/main/_lessons/2022-04-07-alberta-trees-tutorial/Hondo_SoilTemp_2010_CLEAN.csv\", sep=\";\")",
"", "# Merging data", "SR_SoilTemp <- data.frame(stand=as.factor(Hondo_SoilTemp_2010_CLEAN$stand),",
" SR=Hondo_VascularCover_2010_CLEAN$SR,",
" temp_C=Hondo_SoilTemp_2010_CLEAN$temp_C)",
"", "# Species richness as function of soil temperature (C)",
"M1 <- lm(SR ~ temp_C,data = SR_SoilTemp) ", "# Residuals and coefficients of the model",
"(summ_M1 <- summary(M1)) #", "# Simplified ggplot theme",
"library(ggplot2)", "fig <- theme_bw() +", " theme(panel.grid.minor=element_blank(),",
" panel.grid.major=element_blank(),", " panel.background=element_blank()) +",
" theme(strip.background=element_blank(),", " strip.text.y = element_text()) +",
" theme(legend.background=element_blank()) +", " theme(legend.key=element_blank()) +",
" theme(panel.border = element_rect(colour=\"black\", fill=NA))",
"# Plot", "plot <- ggplot(aes(temp_C, SR), data = SR_SoilTemp)",
"Plot_AllData <- plot + geom_point() +", " xlab(\"Soil temperature (C)\") +",
" ylab(\"Species richness\") +", " labs(title = \"All data\") + fig",
"", "# Add regression lines with the intercepts specific to each stand",
"", "Plot_AllData +", " geom_abline(intercept = 23.8756 ,",
" slope = -0.3346, col = \"coral2\")",
"", ""), out.width.px = 624, out.height.px = 384, params.src = "M1_plot, exercise=TRUE, exercise.lines = 36, message=FALSE",
fig.num = 0, exercise.df_print = "paged", exercise.checker = "NULL"),
engine = "r", version = "3"), class = "tutorial_exercise"))
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::question_prerendered_chunk(structure(list(type = "learnr_radio", label = "quizM1-1", question = structure("<strong>What is the relationship beween species richness and soil temperature?<\u002fstrong>", html = TRUE, class = c("html",
"character")), answers = list(structure(list(id = "lnr_ans_a160af6",
option = "More species richness, more soil temperature",
value = "More species richness, more soil temperature", label = structure("More species richness, more soil temperature", html = TRUE, class = c("html",
"character")), correct = FALSE, message = NULL, type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_f4f8c2a",
option = "More species richness, less soil temperature",
value = "More species richness, less soil temperature", label = structure("More species richness, less soil temperature", html = TRUE, class = c("html",
"character")), correct = TRUE, message = NULL, type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_f936df3",
option = "The relationship is not significant", value = "The relationship is not significant",
label = structure("The relationship is not significant", html = TRUE, class = c("html",
"character")), correct = FALSE, message = NULL, type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer")), structure(list(id = "lnr_ans_6e2c1ae",
option = "None of the above answers is correct", value = "None of the above answers is correct",
label = structure("None of the above answers is correct", html = TRUE, class = c("html",
"character")), correct = FALSE, message = NULL, type = "literal"), class = c("tutorial_question_answer",
"tutorial_quiz_answer"))), button_labels = list(submit = structure("<span data-i18n=\"button.questionsubmit\">Submit Answer<\u002fspan>", html = TRUE, class = c("html",
"character")), try_again = structure("<span data-i18n=\"button.questiontryagain\">Try Again<\u002fspan>", html = TRUE, class = c("html",
"character"))), messages = list(correct = structure("Correct!", html = TRUE, class = c("html",
"character")), try_again = structure("Incorrect", html = TRUE, class = c("html",
"character")), incorrect = structure("Incorrect", html = TRUE, class = c("html",
"character")), message = NULL, post_message = NULL), ids = list(
answer = "quizM1-1-answer", question = "quizM1-1"), loading = NULL,
random_answer_order = FALSE, allow_retry = FALSE, seed = 870887445.594461,
options = list()), class = c("learnr_radio", "tutorial_question"
)), session = session)
</script>
<script type="application/shiny-prerendered" data-context="server">
`tutorial-exercise-print-linearityTest-result` <- learnr:::setup_exercise_handler(reactive(req(input$`tutorial-exercise-print-linearityTest-code-editor`)), session)
output$`tutorial-exercise-print-linearityTest-output` <- renderUI({
`tutorial-exercise-print-linearityTest-result`()
})
</script>
<script type="application/shiny-prerendered" data-context="server">
learnr:::store_exercise_cache(structure(list(label = "print-linearityTest", global_setup = NULL,
setup = NULL, chunks = list(list(label = "print-linearityTest",
code = "", opts = list(label = "\"print-linearityTest\"",
exercise = "TRUE", exercise.lines = "25", message = "FALSE",
exercise.eval = "TRUE"), engine = "r")), code_check = NULL,
error_check = NULL, check = NULL, solution = NULL, tests = NULL,
options = list(eval = TRUE, echo = TRUE, results = "markup",
tidy = FALSE, tidy.opts = NULL, collapse = FALSE, prompt = FALSE,
comment = NA, highlight = FALSE, size = "normalsize",
background = "#F7F7F7", strip.white = TRUE, cache = 0,
cache.path = "Biodiversity_Alberta_cache/html/", cache.vars = NULL,
cache.lazy = TRUE, dependson = NULL, autodep = FALSE,
cache.rebuild = FALSE, fig.keep = "high", fig.show = "asis",
fig.align = "default", fig.path = "Biodiversity_Alberta_files/figure-html/",
dev = "png", dev.args = NULL, dpi = 192, fig.ext = "png",
fig.width = 6.5, fig.height = 4, fig.env = "figure",
fig.cap = NULL, fig.scap = NULL, fig.lp = "fig:", fig.subcap = NULL,
fig.pos = "", out.width = 624, out.height = NULL, out.extra = NULL,
fig.retina = 2, external = TRUE, sanitize = FALSE, interval = 1,
aniopts = "controls,loop", warning = TRUE, error = FALSE,
message = FALSE, render = NULL, ref.label = NULL, child = NULL,
engine = "r", split = FALSE, include = TRUE, purl = TRUE,
max.print = 1000, label = "print-linearityTest", exercise = TRUE,
exercise.lines = 25, exercise.eval = TRUE, code = "",
out.width.px = 624, out.height.px = 384, params.src = "print-linearityTest, exercise=TRUE,exercise.lines = 25, message=FALSE, exercise.eval=TRUE",
fig.alt = NULL, fig.num = 0L, exercise.df_print = "paged",
exercise.checker = "NULL"), engine = "r", version = "3"), class = "tutorial_exercise"))
</script>