-
Notifications
You must be signed in to change notification settings - Fork 0
/
R-script_for_thesis.Rmd
2966 lines (2407 loc) · 133 KB
/
R-script_for_thesis.Rmd
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
---
title: "MSc by Thesis-Rscript"
author: "Clare Collins"
date: "`r Sys.Date()`"
output:
pdf_document: default
word_document: default
html_document: default
---
# R script structure and packages
Single \# is a print of the console
Double \## are my notes
Assumes this markdown file is saved in the root folder, data is saved in ./data and items are written out to ./outputs
To shorten the knitted document, only published plots and visual comparisons will show up, everything else can be run through R, but the markdown is set not to show the results within the markdown document ", include=FALSE".
## Install required packages
```
install.packages("tidyverse") (includes ggplot2 and dplyr)
install.packages("ggpubr") ## for ggarrange - arranging plots and checking for normality - recommended by <http://www.sthda.com/english/wiki/normality-test-in-r#check-your-data> and <https://www.datanovia.com/en/lessons/normality-test-in-r/>
install.packages("rempsyc") ##for publication standard tables see <https://rempsyc.remi-theriault.com/articles/t-test> used for getting data from many variables into a data frame, not for presenting final results
install.packages("magittr")
install.packages("knitr") ##to create markdown document
install.packages("car")
install.packages("ggsignif")
install.packages("grid")
install.packages("devtools")
devtools::install_github("thomasp85/patchwork") # patches plots together, like ggarrange, but quickly
install.packages("ggtext")
install.packages("patchwork")
install.packages("egg") ## to layer graphs...but stops ggarrange, so remove where issues arise
```
## Load packages
```{r load-packages, include = FALSE}
##See section above for notes on why each package is needed
library(ggpubr)
library(rempsyc)
library(magrittr)
library(knitr)
library(car)
library(ggsignif)
library(grid)
library(devtools)
library(ggtext)
library(patchwork)
library(tidyverse)
theme_set(theme_classic()) ##set theme
## egg will be loaded and unloaded in the chunk that needs it as it affects ggarrange used elsewhere
```
## References for R and packages used
Citation and references - Bibtex for importing to Zotero
```{r citations, include=FALSE}
#Base R
print(toBibtex(citation()))
##All other packages
## List of packages
packages_list <- c("tidyverse", "ggplot2", "dplyr","ggpubr", "rempsyc", "magrittr", "knitr", "car", "ggsignif", "grid", "ggtext", "patchwork")
## Create an empty character vector to store BibTeX entries
bibtex_entries <- character()
for (pkg in packages_list) {
bib_entry <- capture.output(toBibtex(citation(pkg)))
bibtex_entry <- paste(bib_entry, collapse = "\n")
bibtex_entries <- c(bibtex_entries, bibtex_entry, "\n")
}
# Combine all BibTeX entries into a single BibTeX string
bibtex_string <- paste(bibtex_entries, collapse = "")
# Print the BibTeX string
cat(bibtex_string)
```
# Literature Data
## Recent Interest in MPs
### Import data "WoK_RelPubFishMPs.csv" and sort
```{r import WOK_RelPubFishMPs.csv, include = FALSE}
Publication_Relative_Numbers <- read.csv(file("./data/WOK_RelPubFishMPs.csv"))
str(Publication_Relative_Numbers) ##shows data frame structure including integers, numbers, factors
##Change Relative_Publications column from chr to num
Publication_Relative_Numbers$Relative_Publications <- as.numeric(Publication_Relative_Numbers$Relative_Publications)
##Change Year column from int to num to help display labels correctly
Publication_Relative_Numbers$Year <- as.numeric(Publication_Relative_Numbers$Year)
```
### Figure 1: Microplastics publications have increased more than the general publication rate
Create barchart to identify whether Microplastics publications have increased themselves, or inline with the increase in publication rate in general
Topic search "( \*plastic OR \*plastics ) AND fish\* AND ( ingest\* OR consum\* )" within Web of Knowledge for Years 1933 (start)-2022 (end) Searched 2023-06-22 (n= 2367 in 135 categories) then refined by the top two WoK categories (Environmental Sciences (n= 1317 publications) and Marine Freshwater Biology (n= 705 publications)) compared to all publications in those categories 1,724,817 and 387,288 respectively per year to assess whether there is a relative increase in microplastics publications when considering the actual increase in all publications. No data before 1983 so this is the first year. No microplastics fish ingestion papers before 1990 so maybe worth limiting to this.
```{r barchart_publications, warning=FALSE}
ggplot(Publication_Relative_Numbers, aes(x = Year, y = Relative_Publications))+
geom_col(aes(fill=Category), colour="black", position = "dodge") +
scale_fill_viridis_d()+
scale_y_continuous(expand = c(0,0), labels = scales::percent)+
ylab("Proportion of publications\non fish ingesting plastics\n")+
xlab("\nPublication Year")+
xlim(2000,2023)+
theme(
axis.ticks = element_line(colour = NA),
axis.title.x = element_text(size = rel(1.1)),
axis.title.y = element_text(size = rel(1.1)),
legend.position = "top",
legend.title = element_blank())
```
Many failed attempts to get each year to be displayed on x axis using scale_x\_continuous and breaks; Google and ChatGPT suggest these should work and are not providing other solutions, but they're not, unsure why; also unsure why if I limit the years to 2022, the MFB data isn't showing.
Export png size = 750 x 300
## Figure 3: Antarctica Tourism increase
```{r Antarctica_tourism, include = FALSE}
## packages required: ggplot2 (tidyverse), grid and egg
library(egg)
tourism <- (read.csv(file("./data/antarctic_cruises.csv")))
plot1 <- ggplot(tourism,
aes(tourist.season,
voyages,
fill=event))+
geom_col(position = 'dodge')+
xlab("Tourist season")+
ylab("Number of voyages")+
theme(axis.title.y = element_text(size=11,
margin = margin(r = 10, l = 10)), ## increase space either side of axis title
axis.title.x = element_text(size=11,
margin = margin(t = 10, b = 10)), ## set font size and increase space around axis title
axis.text.y = element_text(size=11),
axis.text.x=element_text(size = 8,
angle = 90,
vjust = 0.5),
legend.title = element_text(size = 11),
legend.text = element_text(size=9))+
scale_fill_discrete(name = "Visiting",
labels = c("Antarctic \n Region", "South \n Georgia"))
plot2 <- ggplot(tourism,
aes(tourist.season,
totalpassenger,
group=event,
colour=event))+
geom_line()+
ylab("Passengers \n (1000s)")+
scale_y_continuous(labels=function(x)x/1000)+
theme(axis.title.y = element_text(size=11,
margin = margin(r = 10, l = 10)), ## increase space either side of axis title
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.text.y=element_text(size = 11),
axis.line.x = element_blank(),
axis.ticks.x = element_blank(),
legend.title = element_text(size = 11),
legend.text = element_text(size=9)) +
scale_colour_discrete(name = "Visiting",
labels = c("Antarctic \n Region", "South \n Georgia"))
tourism <- egg::ggarrange(plot2, plot1, heights = c(0.30, 0.70))
## Export PNG 600 x 400
detach("package:egg", unload=TRUE) #remove egg as affects ggarrange used elsewhere
```
```{r tourism-plot}
tourism
```
Export png size = 600 x 400
## Figures 7-10: Literature Data: Microplastics ingestion by fish
Load data and libraries
```{r literature-data, include = FALSE}
##Uses packages tidyverse, car, ggpubr and ggsignif
##load dataset literature.csv
literature<- read.csv(file("./data/literature.csv"))
#57 obs. of 25 variables
```
### Figure 7: Extraction method barplot
```{r Figure7_extraction}
extract_bar <- ggplot(literature, aes(Extraction)) +
labs(x="Extraction method", ##label x axis
y="Papers using method (n=56)")+ ##label y axis
geom_bar()+
geom_text(aes(label= after_stat(count)), stat="count", nudge_y = -1, colour = "white")+ ##label the count on the bar
theme(
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
extract_bar ##export plot at 600x400
```
Export png size = 600 x 400
### Figure 8 A: Chemicals used for digestion
```{r Figure8A_chemical}
chemdig_bar <-
ggplot(data=subset(literature, !(ChemicalDigestant =="")), aes(x=ChemicalDigestant))+ ##plot Chemical Digestant but ignoring blank rows as these relate to studies that did not use chemical digestion as a method
labs(x="Chemical digestant", ##label x axis
y="Papers using chemical\ndigestion (n=41)")+ ##label y axis
geom_bar()+
scale_x_discrete(limits = c("Potassium hydroxide", "Hydrogen peroxide", "Sodium hydroxide", "Proteinase", "Multi-step"), labels = c("Potassium\nhydroxide", "Hydrogen\nperoxide", "Sodium\nhydroxide", "Proteinase", "Multi-step"))+
geom_text(aes(label= after_stat(count)), stat="count", nudge_y = 1, colour = "black")+
theme(
axis.text.x = element_text(hjust = 0, angle = -45),
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
```
### Figure 8 B: Highest temperature used during digestion
```{r Figure8B_temperature, include=FALSE}
temp_bar <-
ggplot(data=subset(literature, !(Temp =="")), aes(x=Temp))+ ##Ignore the blank rows
labs(x="Digestion temperature (°C)", ##label x axis
y=NULL)+ ##one y axis for the three plots
geom_bar()+
scale_x_discrete(limits = c("Room Temperature", "35-59°C", "60°C", ">60°C"), labels = c("Room\nTemperature", "35-59°C", "60°C", ">60°C"))+
geom_text(aes(label= after_stat(count)), stat="count", nudge_y = 1, colour = "black")+
theme(
axis.text.x = element_text(hjust = 0, angle = -45),
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
```
### Figure 8 C: Digestion duration
```{r Figure8C_duration, include=FALSE}
digdur_bar <-
ggplot(data=subset(literature, !(Duration =="")), aes(x=Duration))+ ## remove the blank rows
labs(x="Digestion duration", ##label x axis
y=NULL)+ ##one y axis for the three plots
geom_bar()+
scale_x_discrete(limits = c("< 1 day", "1 day", "2-7 days", "8-14 days", ">14 days"))+
geom_text(aes(label= after_stat(count)), stat="count", nudge_y = 1, colour = "black")+
theme(
axis.text.x = element_text(hjust = 0, angle = -45),
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
```
### Compile Figure 8 A-C
```{r CompileFigure8A-C, warning=FALSE}
Figure8 <- ggarrange (chemdig_bar, temp_bar, digdur_bar, ncol=3, nrow=1, labels = c("A","B","C"), align="h")
Figure8 ## plot size 900 x 400
```
Export png size = 900 x 400
### Figure 9A: Control methods employed across studies
```{r Figure9AControlMethods, include=FALSE}
##Create df with methods and frequency (possibly a quicker method of doing this somewhere - including in Excel, but for open science, trying to reduce the data uploading where possible)
##Get counts by summing all but blank cells
envcon <- sum(literature$EnvironmentControlled != "") #21
solfilt <- sum(literature$SolutionsFiltered != "") #19
atmcon <- sum(literature$AtmosphericControl != "") #26
procon <- sum(literature$ProceduralControl != "") #22
spike <- sum(literature$SpikeRecovery != "") #4
contr_meth_count <- literature[,c(21:25)] ##create df with just the columns we need
contr_meth_count <- as.data.frame(t(contr_meth_count)) ##transpose ready for counts but as a df rather than a matrix, which is what t usually produces
contr_meth_count$method <- row.names(contr_meth_count) ##insert column with row names
contr_meth_count$count <- c(21, 19, 26, 22, 4) ##insert counts as a column
contr_meth_count <- contr_meth_count[,c(58:59)] ## create final df with just the method name and count columns
rownames(contr_meth_count)<-NULL ##remove row names
## Create plot
controlmeth_bar <- ggplot(contr_meth_count, aes(method,count)) +
labs(x="Contamination control method", ##label x axis
y="Papers using method (n=56)")+ ##label y axis
geom_col()+
coord_cartesian(ylim= c(0,26))+
scale_x_discrete(limits = c("EnvironmentControlled", "SolutionsFiltered", "AtmosphericControl", "ProceduralControl", "SpikeRecovery"), labels = c("Environment\nControlled", "Solutions\nFiltered", "Atmospheric\nControl", "Procedural\nControl", "Spike\nRecovery"))+
geom_text(aes(label= paste(count)), nudge_y = -0.6, colour = "white")+ ##label the count on the bar
theme(
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
controlmeth_bar
```
### Figure 9B: Number of controls employed in each study
```{r Figure9BNumberControls, include=FALSE}
controlnum_bar <- ggplot(literature, aes(NumberControlMethods)) +
labs(x="Number of control methods employed per study",
y=NULL)+ ##No y axis as to right of other plot with same axis
geom_bar()+
scale_x_discrete(limits = c("No controls", "1 controls", "2 controls", "3 controls", "4 controls", "5 controls"))+
coord_cartesian(ylim= c(0,26))+
geom_text(aes(label= after_stat(count)), stat="count", nudge_y = -0.5, colour = "white")+ ##label the count on the bar
theme(
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
controlnum_bar
```
### Compile Figure 9 A & B
```{r CompileFigure9A-B}
Figure9 <- ggarrange (controlmeth_bar, controlnum_bar, ncol=2, nrow=1, labels = c("A","B"), align="h")
Figure9 ## plot size 900 x 400
```
### Figure 10: Plastic Polymer Confirmation Methods
```{r Figure10_PlasticPolymerConfirmation}
##Create df with method, for partial or all particles and frequency for each (possibly a quicker method of doing this somewhere - including in Excel, but for open science, trying to reduce the data uploading where possible)
##Get counts by summing all but blank cells
VisAll <- sum(literature$VisualIDOnly == "All") #11
VisPart <- sum(literature$VisualIDOnly == "Partial") #19
HNAll <- sum(literature$HotNeedle == "All") #4
HNPart <- sum(literature$HotNeedle == "Partial") #3
FTIRAll <- sum(literature$FTIR == "All") #16
FTIRPart <- sum(literature$FTIR == "Partial") #20
RamanAll <- sum(literature$Raman == "All") #6
RamanPart <- sum(literature$Raman == "Partial") #5
PlasticPolymerMethod <- literature[,c(17:20)] ##create df with just the columns we need
PlasticPolymerMethod <- as.data.frame(t(PlasticPolymerMethod)) ##transpose ready for counts but as a df rather than a matrix, which is what t usually produces
PlasticPolymerMethod$method <- row.names(PlasticPolymerMethod) ##insert column with row names
PlasticPolymerMethod2 <- PlasticPolymerMethod ##Create copy of database ready to combine later with rbind
PlasticPolymerMethod$Particles <- c("All", "All", "All", "All") ##insert column with All
PlasticPolymerMethod$count <- c(11, 4, 16, 6) ##insert counts as a column
PlasticPolymerMethod <- PlasticPolymerMethod[,c(58:60)] ## create final df with just the method name and count columns
PlasticPolymerMethod2$Particles <- c("Partial", "Partial", "Partial", "Partial") ##insert column with Partial
PlasticPolymerMethod2$count <- c(19, 3, 20, 5) ##insert counts as a column
PlasticPolymerMethod2 <- PlasticPolymerMethod2[,c(58:60)] ## create final df with just the method name and count columns
rownames(PlasticPolymerMethod)<-NULL ##remove row names
rownames(PlasticPolymerMethod2)<-NULL ##remove row names
PlasticPolymerMethod <- rbind(PlasticPolymerMethod, PlasticPolymerMethod2)
## Create plot
polymerconf_bar <- ggplot(PlasticPolymerMethod, aes(method,count, fill = Particles)) +
labs(x="Plastic polymer identification method", ##label x axis
y="Papers using method (n=56)")+ ##label y axis
geom_col()+
scale_x_discrete(limits = c("VisualIDOnly", "HotNeedle", "FTIR", "Raman"), labels = c("Visual Only", "Hot Needle", "FTIR", "Raman"))+
geom_label(aes(label= paste(count)), position = position_stack(vjust = 0.5), colour = "black", fill="white", label.padding=unit(0.15, "lines"), label.r=unit(0, "lines"), label.size = 0)+ ##label the count on the bar with a white background, no curved corners or border
scale_fill_viridis_d(option="D")+
theme(
axis.title.y = element_text(margin = margin(r = 10)), ## increase space between axis labels and axis title
axis.title.x = element_text(margin = margin(t = 10))) # increase space between axis labels and title
polymerconf_bar ##export plot at 600x400
```
# Thesis Data: Import and subset data
Fish and plastic particles data.
Create factors for Kruskal-Walis later (weight, mouth area and species specific condition).
Separate data for the different contamination control quantification, species and locations.
## Import data "sample_summary.csv" and sort
```{r import-sample_summary.csv, include=FALSE}
DFsummary <- read.csv(file("./data/sample_summary.csv"))
str(DFsummary) ##shows data frame structure including integers, numbers, factors
##Change event column from int to chr
DFsummary$event <- as.character(DFsummary$event)
##Change length_mm and girth_mm from int to num
DFsummary$length_mm <- as.numeric(DFsummary$length_mm)
DFsummary$girth_mm <- as.numeric(DFsummary$girth_mm)
##Change heart_g and liver_g from chr to num
DFsummary$heart_g <- as.numeric(DFsummary$heart_g)
DFsummary$liver_g <- as.numeric(DFsummary$liver_g)
DFsummary$normgut <- DFsummary$gut_g / DFsummary$weight_g ##add a new column 'normgut' where gut weight is divided by wet weight
## Rank normgut weight
DFsummary$gutrank <- rank(DFsummary$normgut)
DFsummary$moutharea <- 3.14 * (DFsummary$hmo_mm / 2) * (DFsummary$vmo_mm / 2) ##add a new column mouth area = pi * (vmo/2) * (hmo/2)
##Create a logical column for whether plastic was present in sample or not
DFsummary$present <- as.logical(DFsummary$total_plastic_particles)
####Subset data
## separate fish and controls
## create dataset with fish samples only
DFsummaryfish <- subset(DFsummary, type == "dig")
## create dataset with fish original data
DFsummaryfishorig <- subset(DFsummaryfish, contamination == "original")
## create dataset with fish conservative correction data
DFsummaryfishcons <- subset(DFsummaryfish, contamination == "conservative")
## create dataset with fish extreme correction data
DFsummaryfishextr <- subset(DFsummaryfish, contamination == "extreme")
## create dataset with procedural controls only
DFsummarypro <- subset(DFsummary, type == "pro")
## create dataset with atmospheric controls only
DFsummaryenv <- subset(DFsummary, type == "env")
## create a dataset with fish measurement data only
DFfishmeasure <- subset(DFsummaryfishorig, plastic.composite == "plastic", select=c('sample', 'event', 'species', 'length_mm', 'girth_mm', 'gapetosnout_mm', 'vmo_mm', 'hmo_mm', 'weight_g', 'gut_g', 'stomach_fullness_index', 'heart_g', 'liver_g', 'condition', 'normgut', "moutharea"
))
##Add a length in cm column
DFfishmeasure$length_cm <- DFfishmeasure$length_mm / 10
##Add a weight category column to use size metrics as a factor
## Understand the spread of data
summary(DFfishmeasure$weight_g)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 28.7 107.0 125.1 123.0 144.0 209.8
##Check factor with 5 equally spaced levels
weightfactor = cut(DFfishmeasure$weight_g, 5)
table(weightfactor)
# (28.5,64.9] (64.9,101] (101,137] (137,174] (174,210]
# 2 7 21 11 2
##add column to DFfishmeasure in g
DFfishmeasure$weight_factor <- cut(DFfishmeasure$weight_g, 5, labels = c("28.5-64.9","64.9-101","101-137", "137-174", "174-210"))
str(DFfishmeasure)
##Add a mouth area category column to use size metrics as a factor
## Understand the spread of data
summary(DFfishmeasure$moutharea)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 132.6 297.1 426.4 572.1 681.8 1569.2
##Check factor with 6 equally spaced levels
mouthareafactor = cut(DFfishmeasure$moutharea, 6)
table(mouthareafactor)
# (131,372] (372,611] (611,851] (851,1.09e+03] (1.09e+03,1.33e+03] (1.33e+03,1.57e+03]
# 15 15 6 1 3 3
##add moutharea category column to DFfishmeasure (changed to cm^2)
DFfishmeasure$mouthareafactor <- cut(DFfishmeasure$moutharea, 6, labels = c("1.31-3.72","3.72-6.11","6.11-8.51", "8.51-10.90", "10.90-13.30", "13.30-15.70"))
str(DFfishmeasure)
##per location
DFfishmeasure13 <- subset(DFfishmeasure, event == "13")
DFfishmeasure26 <- subset(DFfishmeasure, event == "26")
DFfishmeasure53 <- subset(DFfishmeasure, event == "53")
##ANI measurements
DFfishmeasureani <- subset(DFfishmeasure, species == "ANI")
##add a condition category per species to use as a factor
##For ANI
## Understand the spread of data
summary(DFfishmeasureani$condition)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.6913 0.7691 0.8239 0.8207 0.8580 1.0392
##Check factor with 5 equally spaced levels
aniconditionfactor = cut(DFfishmeasureani$condition, 5)
table(aniconditionfactor)
# (0.691,0.761] (0.761,0.83] (0.83,0.9] (0.9,0.97] (0.97,1.04]
# 4 9 6 2 1
##add condition category column to DFfishmeasureani
DFfishmeasureani$condition_factor <- cut(DFfishmeasureani$condition, 5, labels = c("0.69-0.76","0.76-0.83","0.83-0.90", "0.90-0.97", "0.97-1.04"))
str(DFfishmeasureani)
##per location
DFfishmeasureani13 <- subset(DFfishmeasureani, event == "13")
DFfishmeasureani26 <- subset(DFfishmeasureani, event == "26")
##NOG measurements
DFfishmeasurenog <- subset(DFfishmeasure, species == "NOG")
##For NOG
## Understand the spread of data
summary(DFfishmeasurenog$condition)
# Min. 1st Qu. Median Mean 3rd Qu. Max.
# 0.9346 1.2253 1.2854 1.2511 1.3467 1.5177
##Check factor with 5 equally spaced levels
nogconditionfactor = cut(DFfishmeasurenog$condition, 5)
table(nogconditionfactor)
# (0.934,1.05] (1.05,1.17] (1.17,1.28] (1.28,1.4] (1.4,1.52]
# 3 1 6 10 1
##add condition category column to DFfishmeasurenog
DFfishmeasurenog$condition_factor <- cut(DFfishmeasurenog$condition, 5, labels = c("0.93-1.05","1.05-1.17","1.17-1.28", "1.28-1.40", "1.40-1.52"))
str(DFfishmeasurenog)
##per location
DFfishmeasurenog13 <- subset(DFfishmeasurenog, event == "13")
DFfishmeasurenog26 <- subset(DFfishmeasurenog, event == "26")
DFfishmeasurenog53 <- subset(DFfishmeasurenog, event == "53")
## separate species data to plot both
## create dataset with ANI fish
DFsummaryani <- subset(DFsummaryfish, species == "ANI")
## create dataset with ANI original data
DFsummaryaniorig <- subset(DFsummaryani, contamination == "original")
## create dataset with ANI conservative correction data
DFsummaryanicons <- subset(DFsummaryani, contamination == "conservative")
## create dataset with ANI extreme correction data
DFsummaryaniextr <- subset(DFsummaryani, contamination == "extreme")
## create dataset with NOG fish
DFsummarynog <- subset(DFsummaryfish, species == "NOG")
## create dataset with NOG original data
DFsummarynogorig <- subset(DFsummarynog, contamination == "original")
## create dataset with NOG conservative correction data
DFsummarynogcons <- subset(DFsummarynog, contamination == "conservative")
## create dataset with NOG extreme correction data
DFsummarynogextr <- subset(DFsummarynog, contamination == "extreme")
## create dataset of Event 13 fish
DFsummary13 <- subset(DFsummaryfish, event == "13")
## create dataset with ev13 original data
DFsummary13orig <- subset(DFsummary13, contamination == "original")
## original data ev13 by species
DFsummary13origANI <- subset(DFsummary13orig, species == "ANI")
DFsummary13origNOG <- subset(DFsummary13orig, species == "NOG")
## create dataset with ev13 conservative correction data
DFsummary13cons <- subset(DFsummary13, contamination == "conservative")
## create dataset with ev13 extreme correction data
DFsummary13extr <- subset(DFsummary13, contamination == "extreme")
## create dataset of Event 26 fish
DFsummary26 <- subset(DFsummaryfish, event == "26")
## create dataset with ev26 original data
DFsummary26orig <- subset(DFsummary26, contamination == "original")
## original data ev13 by species
DFsummary26origANI <- subset(DFsummary26orig, species == "ANI")
DFsummary26origNOG <- subset(DFsummary26orig, species == "NOG")
## create dataset with ev26 conservative correction data
DFsummary26cons <- subset(DFsummary26, contamination == "conservative")
## create dataset with ev26 extreme correction data
DFsummary26extr <- subset(DFsummary26, contamination == "extreme")
## create dataset of Event 26 and 53 (North West) fish
DFsummaryNW <- subset(DFsummaryfish, event %in% c("26", "53"))
## create dataset with evNW original data
DFsummaryNWorig <- subset(DFsummaryNW, contamination == "original")
## create dataset with evNW conservative correction data
DFsummaryNWcons <- subset(DFsummaryNW, contamination == "conservative")
## create dataset with evNW extreme correction data
DFsummaryNWextr <- subset(DFsummaryNW, contamination == "extreme")
```
## Import data "particle_data.csv" and sort
```{r import-particle_data.csv, include=FALSE}
DFparticles <- read.csv(file("./data/particle_data.csv"))
##Change event column from int to chr
DFparticles$event <- as.character(DFparticles$event)
##Change sample column from int to chr
DFparticles$sample <- as.character(DFparticles$sample)
##subset fish and controls
DFparticlesfish <- subset(DFparticles, fp_type == "dig")
DFparticlespro <- subset(DFparticles, fp_type == "pro")
DFparticlesenv <- subset(DFparticles, fp_type == "env")
```
## Import data "control_summaries.csv" and sort
```{r import-control_summaries.csv, include=FALSE}
##plastics on control papers combined (plastics and composites)
DFcontrolsumm <- read.csv(file("./data/control_summaries.csv"))
##Change event column from int to chr
DFcontrolsumm$event <- as.character(DFcontrolsumm$event)
```
## Import data "sample_summary_combinedplastic.csv" and sort
This data is where plastics and composites are counted together rather than separated, so total count is the combined total
```{r import-sample_summary_combinedplastic.csv, include=FALSE}
##plastics in fish combined (plastics and composites)
DFsummarycombined <- read.csv(file("./data/sample_summary_combinedplastic.csv"))
##Change event column from int to chr
DFsummarycombined$event <- as.character(DFsummarycombined$event)
## create dataset with ANI original data (without contamination correction)
DFsummarycombinedorig <- subset(DFsummarycombined, contamination == "original")
```
# Fish Measurement Data Analysis
1. Explore fish measurements, summarising, checking assumptions and plotting.
2. Look at the plastics in the fish.
3. Look at relationships between plastics ingested and fish species, locations and measurements
## Fish measurements
First plotting lengths to show similarity across locations and species
### Figure 16 - Boxplot lengths across locations and species
```{r boxplot_length, include = FALSE}
##facet wrap
lengthwrap <- filter(DFfishmeasure, length_cm != "", species != "", event != "")
lengthcount <- count(lengthwrap, length_cm, event, species)
glimpse(lengthcount)
lengthcount <- filter(lengthcount, species%in%c("ANI", "NOG")) %>%
mutate(species = factor(species, levels = c("ANI", "NOG")))
##subset lengthcount per location
lengthcount53NW <- subset(lengthcount, event == 53)
lengthcount26W <- subset(lengthcount, event == 26)
lengthcount13SE <- subset(lengthcount, event == 13)
## create boxplots for ggarrange
boxSElength <-
ggplot(lengthcount13SE, aes(group = species,
fill=species,
y = length_cm,
factor(species,
labels = c("C. gunnari", "G. gibberifrons")))) + ##label species factors 0, 1 as C. gunnari and G. gibberifrons respectively
stat_boxplot(geom ='errorbar', width = 0.6) +
geom_boxplot(color="black") +
scale_fill_manual(values = c("ANI" = "#3F4788",
"NOG"="#B8DE29"), name = "Species", labels = c("C. gunnari", "G. gibberifrons"))+
stat_summary(fun=mean, geom="point", shape=20, size=2.5, color="#BFD5E3") +
xlab(NULL)+ ##no x axis label as species already obvious
ylab('Length (cm)')+ ##y axis label
ylim(10,30)+
theme(
axis.text.x = element_text(size = rel(1.2)),
axis.text.y = element_text(size = rel(1.5)),
legend.text = element_text(size = rel(1.3)),
legend.title = element_text(size = rel(1.2)),
axis.title.y = element_text(margin = margin(r = 10), size = rel(1.2)) ## increase space between axis labels and axis title
)+
ggtitle("Southeast")
boxWlength <-
ggplot(lengthcount26W, aes(group = species,
fill=species,
y = length_cm,
factor(species,
labels = c("C. gunnari", "G. gibberifrons")))) + ##label species factors 0, 1 as C. gunnari and G. gibberifrons respectively
stat_boxplot(geom ='errorbar', width = 0.6) +
geom_boxplot(color="black") +
scale_fill_manual(values = c("ANI" = "#3F4788",
"NOG"="#B8DE29"), name = "Species", labels = c("C. gunnari", "G. gibberifrons"))+
stat_summary(fun=mean, geom="point", shape=20, size=2.5, color="#BFD5E3") +
xlab(NULL)+ ##no x axis label as species already obvious
ylab('Length (cm)')+ ##y axis label
ylim(10,30)+
theme(
axis.text.x = element_text(size = rel(1.2)),
axis.text.y = element_text(size = rel(1.5)),
legend.text = element_text(size = rel(1.3)),
legend.title = element_text(size = rel(1.2)),
axis.title.y = element_text(margin = margin(r = 10), size = rel(1.2)) ## increase space between axis labels and axis title
)+
ggtitle("West")
boxNWlength <-
ggplot(lengthcount53NW, aes(group = species,
fill=species,
y = length_cm,
factor(species,
labels = c("G. gibberifrons")))) + ##label species factors 0, 1 as C. gunnari and G. gibberifrons respectively
stat_boxplot(geom ='errorbar', width = 0.6) +
geom_boxplot(color="black") +
scale_fill_manual(values = c("NOG"="#B8DE29"), name = "Species", labels = c("G. gibberifrons"))+
stat_summary(fun=mean, geom="point", shape=20, size=2.5, color="#BFD5E3") +
xlab(NULL)+ ##no x axis label as species already obvious
ylab('Length (cm)')+ ##y axis label
ylim(10,30)+
theme(
axis.text.x = element_text(size = rel(1.2)),
axis.text.y = element_text(size = rel(1.5)),
legend.text = element_text(size = rel(1.3)),
legend.title = element_text(size = rel(1.2)),
axis.title.y = element_text(margin = margin(r = 10), size = rel(1.2)) ## increase space between axis labels and axis title
)+
ggtitle("Northwest")
boxloclength <- ggarrange (boxSElength, boxWlength, boxNWlength, ncol=3, nrow=1, labels = c("A","B","C"), common.legend = TRUE, legend = "bottom")
```
```{r display-boxloclength}
boxloclength
```
### Table 7 T-tests
The morphometric data was checked for normality using visual (histogram, density plots and QQplots) and statistical (Shapiro-Wilks) methods and for homoscedasticity using Bartlett's test. Fish measurements were then checked between species for differences, visually using boxplots and 1460 statistically using the Student t-test (for normally distributed and homoscedastic data), Welch's t-test (for normally distributed heteroscedastic data) or a Mann-Whitney U/ Wilcoxon Rank Sum test (for not normally distributed, but similarly distributed data, examined visually using histograms).
#### Check visually for normal distribution of fish measurements per species
Histograms plots species measurements:
```{r fishmeasure-histograms, warning = FALSE, message = FALSE}
## Set up multiple plots side by side with histogram to check for bell-shape
hislen <- ggplot(DFfishmeasure, aes(x = length_cm, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Length (cm)")
hiswei <- ggplot(DFfishmeasure, aes(x = weight_g, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Weight (wet)")
hisma <- ggplot(DFfishmeasure, aes(x = moutharea, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Mouth Area")
hisgut <- ggplot(DFfishmeasure, aes(x = gut_g, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Gut weight (wet)")
hisg2s <- ggplot(DFfishmeasure, aes(x = gapetosnout_mm, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Gape to snout")
hisvmo <- ggplot(DFfishmeasure, aes(x = vmo_mm, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Vertical Mouth Opening")
hishmo <- ggplot(DFfishmeasure, aes(x = hmo_mm, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Horizontal Mouth Opening")
hissfi <- ggplot(DFfishmeasure, aes(x = stomach_fullness_index, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Stomach Fullness Index")
hishea <- ggplot(DFfishmeasure, aes(x = heart_g, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Heart weight")
hiscon <- ggplot(DFfishmeasure, aes(x = condition, fill = species, colour = species)) +
geom_histogram(alpha = 0.5, position = "identity") +
ggtitle("Body condition (factor K)")
ggarrange (hislen, hiswei, hisma, hisgut, hisg2s, hisvmo, hishmo, hissfi, hishea, hiscon, ncol=5, nrow=2, labels = c("A","B","C","D","E","F", "G", "H", "I","J"), common.legend = TRUE, legend = "bottom")
```
Density plots species measurements
```{r fishmeasure-density, warning = FALSE}
####### Density Plots Fish Measurements-------
denlen <- ggplot(DFfishmeasure, aes(x=length_cm, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Length")
denwei <- ggplot(DFfishmeasure, aes(x=weight_g, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Wet weight")
denma <- ggplot(DFfishmeasure, aes(x=moutharea, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Mouth Area")
dengut <- ggplot(DFfishmeasure, aes(x=gut_g, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Gut weight(wet)")
deng2s <- ggplot(DFfishmeasure, aes(x=gapetosnout_mm, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Gape to snout length")
denvmo <- ggplot(DFfishmeasure, aes(x=vmo_mm, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Vertical Mouth Opening length")
denhmo <- ggplot(DFfishmeasure, aes(x=hmo_mm, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Horizontal Mouth Opening length")
densfi <- ggplot(DFfishmeasure, aes(x = stomach_fullness_index, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Stomach Fullness Index")
denhea <- ggplot(DFfishmeasure, aes(x = heart_g, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Heart weight")
dencon <- ggplot(DFfishmeasure, aes(x = condition, fill = species, colour = species)) +
geom_density(alpha = 0.5, position = "identity") +
ggtitle("Body condition (factor K)")
ggarrange (denlen, denwei, denma, dengut, deng2s, denvmo, denhmo, densfi, denhea, dencon, ncol=5, nrow=2, labels = c("A","B","C","D","E","F", "G", "H", "I", "J"), common.legend = TRUE, legend = "bottom")
```
QQplots species measurements
```{r fishmeasure-qqplot, warning=FALSE}
####### QQ plot Fish Measurements -------
qqlen <- ggplot(DFfishmeasure, aes(sample=length_cm, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Length")
qqwei <- ggplot(DFfishmeasure, aes(sample=weight_g, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Weight(wet)")
qqma <- ggplot(DFfishmeasure, aes(sample=moutharea, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Mouth Area")
qqgut <- ggplot(DFfishmeasure, aes(sample=gut_g, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Gut weight (wet)")
qqg2s <- ggplot(DFfishmeasure, aes(sample=gapetosnout_mm, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Gape to Snout Length")
qqvmo <- ggplot(DFfishmeasure, aes(sample=vmo_mm, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Vertical mouth opening")
qqhmo <- ggplot(DFfishmeasure, aes(sample=hmo_mm, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Horizontal mouth opening")
qqsfi <- ggplot(DFfishmeasure, aes(sample=stomach_fullness_index, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Stomach Fullness Index")
qqhea <- ggplot(DFfishmeasure, aes(sample=heart_g, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Heart weight")
qqcon <- ggplot(DFfishmeasure, aes(sample=condition, colour = factor(species))) +
stat_qq() +
stat_qq_line() +
ggtitle("Body condition (factor K)")
ggarrange (qqlen, qqwei, qqma, qqgut, qqg2s, qqvmo, qqhmo, qqsfi, qqhea, qqcon, ncol=5, nrow=2, labels = c("A","B","C","D","E","F", "G", "H", "I", "J"), common.legend = TRUE, legend = "bottom")
```
#### Checking for normality statistically (Shapiro-Wilks) per species
```{r normaldist-measurements-statistical, include=FALSE}
######Are the fish measurements normally distributed - statistical######
###### Shapiro-Wilk's Fish Measure per species------
## Run a significance test: Shapiro-Wilk's method based on correlation between the data and the corresponding normal scores
shapiro.test(DFfishmeasureani$length_mm)
# W = 0.86215, p-value = 0.005611 ## not normal
shapiro.test(DFfishmeasureani$weight_g)
# W = 0.92191, p-value = 0.08327 ## normal
shapiro.test(DFfishmeasureani$gut_g)
# W = 0.81177, p-value = 0.0007693 ## not normal
shapiro.test(DFfishmeasureani$moutharea)
# W = 0.89771, p-value = 0.02676 ## not normal
shapiro.test(DFfishmeasureani$gapetosnout_mm)
# W = 0.95256, p-value = 0.3546 ## normal
shapiro.test(DFfishmeasureani$vmo_mm)
# W = 0.91171, p-value = 0.05131 ## normal
shapiro.test(DFfishmeasureani$hmo_mm)
# W = 0.95832, p-value = 0.456 ## normal
shapiro.test(DFfishmeasureani$stomach_fullness_index)
# W = 0.88231, p-value = 0.01338 ## not normal
shapiro.test(DFfishmeasureani$heart_g)
# W = 0.96703, p-value = 0.6425 ## normal
shapiro.test(DFfishmeasureani$condition)
# W = 0.94421, p-value = 0.2415 ## normal
shapiro.test(DFfishmeasurenog$length_mm)
# W = 0.92569, p-value = 0.1128 ## normal
shapiro.test(DFfishmeasurenog$weight_g)
# W = 0.98528, p-value = 0.9803 ## normal
shapiro.test(DFfishmeasurenog$gut_g)
# W = 0.96142, p-value = 0.5451 ## normal
shapiro.test(DFfishmeasurenog$moutharea)
# W = 0.96784, p-value = 0.6848 ## normal
shapiro.test(DFfishmeasurenog$gapetosnout_mm)
# W = 0.9556, p-value = 0.4322 ## normal
shapiro.test(DFfishmeasurenog$vmo_mm)
# W = 0.97707, p-value = 0.8781 ## normal
shapiro.test(DFfishmeasurenog$hmo_mm)
# W = 0.9729, p-value = 0.7961 ## normal
shapiro.test(DFfishmeasurenog$stomach_fullness_index)
# W = 0.76195, p-value = 0.0001816 ## not normal
shapiro.test(DFfishmeasurenog$heart_g)
# W = 0.84323, p-value = 0.004113 ## not normal
shapiro.test(DFfishmeasurenog$condition)
# W = 0.91151, p-value = 0.0588 ## normal
```
#### Test for homoscedasticity between species
(equal variance across groups) using Bartlett's test. If p-value \>= 0.05, group measurements are homoscedastic, use var.equal=TRUE in the T Test.
```{r fishmeasure-homoscedascity stats, include=FALSE}
bartlett.test(length_cm ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: length_cm by species
# Bartlett's K-squared = 3.0988, df = 1, p-value = 0.07835
bartlett.test(weight_g ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: weight_g by species
# Bartlett's K-squared = 4.8011, df = 1, p-value = 0.02844 ###NOT HOMOSCEDASTIC
bartlett.test(moutharea ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: moutharea by species
# Bartlett's K-squared = 23.825, df = 1, p-value = 1.055e-06 ###NOT HOMOSCEDASTIC
bartlett.test(gut_g ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: gut_g by species
# Bartlett's K-squared = 0.11696, df = 1, p-value = 0.7324
bartlett.test(gapetosnout_mm ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: gapetosnout_mm by species
# Bartlett's K-squared = 0.69718, df = 1, p-value = 0.4037
bartlett.test(vmo_mm ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: vmo_mm by species
# Bartlett's K-squared = 10.528, df = 1, p-value = 0.001176 ###NOT HOMOSCEDASTIC
bartlett.test(hmo_mm ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: hmo_mm by species
# Bartlett's K-squared = 6.1029, df = 1, p-value = 0.0135 ###NOT HOMOSCEDASTIC
bartlett.test(heart_g ~ species, data = DFfishmeasure)
# Bartlett test of homogeneity of variances
#
# data: heart_g by species
# Bartlett's K-squared = 23.737, df = 1, p-value = 1.104e-06 ###NOT HOMOSCEDASTIC