library(readxl)
## Warning: package 'readxl' was built under R version 4.4.2
bird_Ohio <- read_excel("C:/Users/LENOVO/Downloads/bird_Ohio.xlsx")
## New names:
## • `` -> `...1`
env_Ohio <- read_excel("env_Ohio.xlsx")
## New names:
## • `` -> `...1`
library(vegan)
## Warning: package 'vegan' was built under R version 4.4.2
## Loading required package: permute
## Warning: package 'permute' was built under R version 4.4.2
## Loading required package: lattice
## This is vegan 2.6-8
bird_Ohio
ncol(bird_Ohio)
## [1] 49
sp.rich<-specnumber(bird_Ohio, MARGIN=1)
as.data.frame(sp.rich)
sp.even<-specnumber(bird_Ohio,MARGIN=2)
as.data.frame(sp.even)
shannon<-diversity(bird_Ohio, index = "shannon")
shannon
##   [1] 1.8917399 2.5122269 2.5759511 2.5306341 2.5813695 2.5851922 2.8543118
##   [8] 2.6869090 2.6290101 2.4471082 2.4514742 2.6624436 2.4801533 2.4524231
##  [15] 2.4446459 2.5985159 2.1580650 2.0290131 2.3439848 2.3677896 2.6230152
##  [22] 2.1818266 2.3999167 2.3497389 2.1019228 2.1558323 2.1542864 2.2277483
##  [29] 2.3289428 1.8809617 2.4493401 2.3266446 2.2270348 1.9964440 2.0417370
##  [36] 2.4618897 2.1320689 2.2922720 1.5430953 2.0627115 2.6546098 2.3331170
##  [43] 1.7535317 1.8944254 1.9905828 1.8202840 1.7588983 1.2049611 2.1437307
##  [50] 2.0737966 1.6534827 2.1077805 1.9625262 1.7738141 2.0210011 1.8759969
##  [57] 1.4522335 1.5969316 1.4228140 2.2233828 1.6941131 2.2527933 1.4705667
##  [64] 1.4376671 1.6556983 2.0069460 1.7242396 1.6262868 1.9412633 1.2809809
##  [71] 1.3010760 1.5318794 1.5531853 1.5204937 1.7648837 1.6943305 1.7000499
##  [78] 1.3091997 1.5702975 1.3837769 1.3385135 1.4513903 0.9429183 1.4490505
##  [85] 1.7895111 1.9656594 1.5788314 1.5022623 1.4904512 1.4962931 1.4059042
##  [92] 1.6478061 1.2990656 1.0930459 1.5543977 1.7289643 1.6443609 1.5495614
##  [99] 1.4031313 1.7226377 1.8883235 1.9303606 1.4901640 1.5787674 1.5705318
## [106] 1.4178638 1.2837894 1.5926701 1.6081552 1.4082954 1.2234179 1.2528753
## [113] 1.3100790 1.4507992 1.2323738 1.3797947 1.7293521 1.4854109 1.4658616
## [120] 0.9669648 1.1795715 1.3672704 1.5350481 1.3090028 1.2126036 1.3047201
## [127] 1.2040135 1.3639687 1.1349332 1.4067959 1.2394246 1.3198667 1.1560033
## [134] 1.2668167 1.3633187 1.7184293 1.4705114 1.4134997 1.1657677 1.4382794
## [141] 1.6241226 0.9479850 0.7890530 1.4545973 1.4366209 1.3270892 1.1408832
## [148] 0.9003295 0.9349969 1.1903317 1.5749987 1.5003813 1.0810697 1.5488876
## [155] 1.5759803 0.9573217 1.2080605 1.1433944 1.0993195 1.1174376 1.1019272
## [162] 0.9943400 1.0646499 1.6364990 1.2202461 1.3055935 1.2551904 1.3908337
## [169] 1.5319849 0.9827985 0.9091475 1.3284004 1.0280144 1.0155201 0.8256294
## [176] 1.1407526 1.1095773 0.9370976 1.1957853 0.9132408 0.9268789 0.9070407
## [183] 0.9184634 1.0505849 1.1130730 1.1475092 0.8861070 1.1679846 1.3269686
## [190] 1.4025824 0.7316835 1.0732068 1.0880649 0.8289934 0.8676827 1.1044350
## [197] 1.0755235 1.0144104 1.1081660 1.0762302 1.0511711 0.9282779 1.2321592
## [204] 0.7472004 0.8967415 0.9696155 0.4879819 1.2601278 1.2607309 1.0734488
simpson<-diversity(bird_Ohio, index = "simpson")
simpson
##   [1] 0.7923875 0.9023669 0.9141051 0.8955078 0.9112426 0.9100346 0.9286265
##   [8] 0.9171429 0.9131944 0.8927116 0.8897290 0.9137893 0.8793388 0.8758573
##  [15] 0.8830959 0.8967347 0.8536155 0.8264046 0.8624852 0.8617998 0.8762865
##  [22] 0.8433163 0.8526139 0.8573088 0.8130987 0.8250548 0.8136574 0.8264701
##  [29] 0.8491358 0.7441406 0.8553590 0.8238062 0.8106576 0.7780612 0.7801904
##  [36] 0.8531268 0.7831946 0.8068698 0.6477631 0.7808963 0.8616564 0.7890625
##  [43] 0.6954194 0.7339693 0.7269136 0.6911844 0.6822566 0.5081633 0.7527571
##  [50] 0.7694515 0.6567901 0.7160000 0.7361333 0.6479362 0.6747189 0.6863983
##  [57] 0.5658574 0.6459054 0.5912465 0.7710506 0.6341785 0.7706531 0.5559896
##  [64] 0.5789628 0.6272199 0.7150879 0.6403025 0.6024793 0.7088021 0.4988000
##  [71] 0.4968140 0.5861804 0.5995339 0.5778835 0.6374853 0.6346974 0.6039282
##  [78] 0.4959013 0.5915848 0.5347080 0.5234094 0.5429308 0.4238292 0.5318678
##  [85] 0.6617778 0.6964237 0.5921019 0.5775047 0.5791837 0.5853587 0.5223585
##  [92] 0.6010774 0.5181661 0.4416889 0.5807846 0.6220482 0.5677222 0.5565515
##  [99] 0.5220452 0.5952296 0.6635526 0.6503184 0.5207111 0.6158734 0.5447686
## [106] 0.5379747 0.4695946 0.5760346 0.5821278 0.5175781 0.5051503 0.4630629
## [113] 0.4962000 0.5478637 0.4671492 0.5235294 0.6090305 0.5106574 0.5185606
## [120] 0.3701524 0.4405887 0.5040980 0.5602648 0.4785325 0.4391298 0.4572742
## [127] 0.4574581 0.4963772 0.4396221 0.5037577 0.4670187 0.4978497 0.4104902
## [134] 0.4898061 0.4876454 0.5769861 0.5051541 0.5225468 0.3938079 0.5078587
## [141] 0.5466634 0.3572150 0.3180077 0.4964437 0.4751863 0.4889245 0.4303415
## [148] 0.3341988 0.3763435 0.4262014 0.5111597 0.5117908 0.4075500 0.5420794
## [155] 0.5161432 0.3428280 0.4343764 0.4120049 0.4084227 0.3921670 0.4009981
## [162] 0.3344865 0.4009879 0.5320156 0.4317769 0.4590037 0.4250527 0.4708680
## [169] 0.5338560 0.3637872 0.3495779 0.4747466 0.3657520 0.3795146 0.2896172
## [176] 0.4219639 0.4203375 0.3414050 0.4325555 0.3431800 0.3372680 0.3009006
## [183] 0.3442333 0.3724143 0.3960015 0.3812779 0.3234457 0.4113292 0.4541780
## [190] 0.4803133 0.2576901 0.3719623 0.3935743 0.2681985 0.3192152 0.3765746
## [197] 0.3795178 0.3771101 0.3910828 0.3889234 0.3824131 0.3371236 0.4337904
## [204] 0.2852947 0.3188013 0.3529198 0.1674397 0.4239074 0.4304125 0.3842678
inv.simpson<-diversity(bird_Ohio, index = "invsimpson")
inv.simpson 
##   [1]  4.816667 10.242424 11.642140  9.570093 11.266667 11.115385 14.010811
##   [8] 12.068966 11.520000  9.320675  9.068571 11.599483  8.287671  8.055249
##  [15]  8.554023  9.683794  6.831325  5.760522  7.271945  7.235880  8.083192
##  [22]  6.382284  6.784902  7.008138  5.350417  5.716075  5.366460  5.762696
##  [29]  6.628478  3.908397  6.913669  5.675570  5.281437  4.505747  4.549391
##  [36]  6.808596  4.612431  5.177854  2.838998  4.564050  7.228380  4.740741
##  [43]  3.283203  3.758965  3.661844  3.238179  3.147193  2.033195  4.044605
##  [50]  4.337483  2.913669  3.521127  3.789793  2.840394  3.074264  3.188759
##  [57]  2.303391  2.824104  2.446462  4.367778  2.733574  4.360207  2.252199
##  [64]  2.375087  2.682547  3.509854  2.780114  2.515593  3.434090  1.995211
##  [71]  1.987337  2.416512  2.497090  2.369014  2.758509  2.737457  2.524795
##  [78]  1.983739  2.448489  2.149188  2.098237  2.187852  1.735597  2.136149
##  [85]  2.956636  3.294065  2.451592  2.366890  2.376334  2.411723  2.093621
##  [92]  2.506752  2.075404  1.791116  2.385409  2.645840  2.313327  2.255053
##  [99]  2.092248  2.470536  2.972233  2.859744  2.086424  2.603309  2.196685
## [106]  2.164384  1.885350  2.358683  2.393076  2.072874  2.020815  1.862416
## [113]  1.984915  2.211722  1.876698  2.098765  2.557744  2.043558  2.077105
## [120]  1.587686  1.787593  2.016527  2.274096  1.917665  1.782944  1.842551
## [127]  1.843175  1.985613  1.784510  2.015144  1.876238  1.991436  1.696325
## [134]  1.960039  1.951773  2.363989  2.020831  2.094446  1.649642  2.031937
## [141]  2.205866  1.555730  1.466292  1.985875  1.905438  1.956658  1.755438
## [148]  1.501950  1.603447  1.742772  2.045658  2.048302  1.687906  2.183785
## [155]  2.066727  1.521672  1.767960  1.700695  1.690396  1.645189  1.669444
## [162]  1.502599  1.669415  2.136824  1.759872  1.848441  1.739290  1.889888
## [169]  2.145260  1.571801  1.537463  1.903843  1.576670  1.611642  1.407692
## [176]  1.729996  1.725142  1.518384  1.762287  1.522487  1.508906  1.430412
## [183]  1.524933  1.593408  1.655633  1.616235  1.478078  1.698742  1.832099
## [190]  1.924236  1.347146  1.592261  1.649007  1.366491  1.468893  1.604041
## [197]  1.611650  1.605420  1.642259  1.636456  1.619205  1.508577  1.766130
## [204]  1.399178  1.468000  1.545403  1.201114  1.735832  1.755657  1.624083
fish.alp<-fisher.alpha(bird_Ohio)
fish.alp
##   [1]  5.642066  7.896600  6.488217  7.565648  7.896600  7.275326 11.680602
##   [8]  8.578491  7.703286  7.612305  7.916266  8.839863  9.316717  9.454690
##  [15]  7.814550  9.354043  4.970140  4.970140  6.781181  7.415136 11.156386
##  [22]  5.110244  9.198544  7.705935  5.389613  5.679263  6.377738  6.055108
##  [29]  6.765902  4.927590  7.224522  8.920683  7.027652  6.430958  5.381526
##  [36]  8.310228  6.891754  8.984035  3.690822  5.538659 11.970603  9.586698
##  [43]  4.350582  5.112918  6.765902  5.254828  4.718079  3.192559  7.976087
##  [50]  5.576450  3.718729  9.354332  5.646225  6.096825 10.837223  5.798205
##  [57]  4.212510  4.392532  3.217794  7.064403  4.829737  8.991549  4.986195
##  [64]  3.546422  4.711590  6.648249  5.988234  6.114229  6.065899  3.560586
##  [71]  3.546422  4.192993  5.427384  5.030672  5.726751  5.687885  6.259378
##  [78]  4.238987  4.858106  4.121275  3.717707  5.349775  1.659647  4.890459
##  [85]  4.931276  7.342929  5.082987  4.281400  4.257961  4.223961  4.342856
##  [92]  5.369842  3.173985  2.544462  4.545684  6.048954  7.602821  5.778996
##  [99]  5.414712  7.383522  6.606168  7.981444  7.105981  3.601971  6.964669
## [106]  4.071694  4.557373  5.109555  5.469168  4.810390  3.335706  4.489371
## [113]  4.415941  4.311580  4.062475  3.967505  6.848485  7.622560  6.259936
## [120]  3.401558  4.396019  5.031600  5.661968  4.672620  5.506903  6.274631
## [127]  3.935634  4.959159  3.588003  5.297514  3.882807  3.497519  5.042383
## [134]  4.164308  5.639364  8.224130  6.763796  4.777415  5.769443  5.149475
## [141]  7.797693  3.904973  2.305868  5.871991  7.955229  4.394232  3.450861
## [148]  3.204387  2.846412  4.802582  8.995673  6.871785  3.756033  6.745033
## [155]  8.446768  3.800210  4.713438  4.046218  4.379899  5.104476  4.033430
## [162]  5.926942  4.014640  8.614307  5.345689  5.647828  6.075704  6.342263
## [169]  6.915739  3.675202  2.750911  4.849896  4.653569  3.632950  3.708700
## [176]  4.551192  3.574193  3.328464  4.513385  3.010270  3.314740  5.730437
## [183]  3.296916  4.218990  4.513385  5.923958  3.292541  4.471297  6.113701
## [190]  6.406272  3.014282  5.165024  4.453883  5.647828  2.957055  6.182347
## [197]  4.772041  3.494964  4.741473  4.409155  4.409155  3.815290  4.655622
## [204]  2.103496  3.815290  3.778652  2.415700  6.323830  5.950260  4.993876
Div.Ind<-cbind.data.frame(shannon, simpson, inv.simpson,fish.alp)
Div.Ind
summary(Div.Ind)
##     shannon         simpson        inv.simpson        fish.alp     
##  Min.   :0.488   Min.   :0.1674   Min.   : 1.201   Min.   : 1.660  
##  1st Qu.:1.171   1st Qu.:0.4272   1st Qu.: 1.746   1st Qu.: 4.214  
##  Median :1.453   Median :0.5277   Median : 2.117   Median : 5.112  
##  Mean   :1.559   Mean   :0.5678   Mean   : 3.192   Mean   : 5.521  
##  3rd Qu.:1.891   3rd Qu.:0.6944   3rd Qu.: 3.272   3rd Qu.: 6.638  
##  Max.   :2.854   Max.   :0.9286   Max.   :14.011   Max.   :11.971
env_Ohio
Ohio.env.Div<-cbind.data.frame(env_Ohio, Div.Ind)
Ohio.env.Div
library("rstatix")
## Warning: package 'rstatix' was built under R version 4.4.2
## 
## Attaching package: 'rstatix'
## The following object is masked from 'package:stats':
## 
##     filter
Ohio.env.Div %>%
  group_by(Habitat) %>%
  get_summary_stats(shannon, type = "mean_sd")
Ohio.env.Div %>%
  group_by(Habitat) %>%
  get_summary_stats(simpson, type = "mean_sd")
Ohio.env.Div %>%
  group_by(Habitat) %>%
  get_summary_stats(fish.alp, type = "mean_sd")
Ohio.env.Div %>%
  group_by(Habitat) %>%
  get_summary_stats(inv.simpson, type = "mean_sd") 
library("ggplot2")
## Warning: package 'ggplot2' was built under R version 4.4.2
Shanon.habitat<-ggplot(Ohio.env.Div, aes(x = Habitat, y = shannon, fill = Habitat)) +
  geom_boxplot() + 
  stat_summary(fun = mean, geom = "point", shape =21, size = 3, colour = "black", fill="yellow")

Simp.habitat<-ggplot(Ohio.env.Div, aes(x = Habitat, y = simpson, fill = Habitat)) +
  geom_boxplot() +
  stat_summary(fun = mean, geom = "point", shape =21, size = 3, colour = "black", fill="yellow")

InvSimp.habitat<-ggplot(Ohio.env.Div, aes(x = Habitat, y = inv.simpson, fill = Habitat)) +
  geom_boxplot()  + 
  stat_summary(fun = mean, geom = "point", shape =21, size = 3, colour = "black", fill="yellow")

Fish.habitat<-ggplot(Ohio.env.Div, aes(x = Habitat, y = fish.alp, fill = Habitat)) +
  geom_boxplot()  + 
  stat_summary(fun = mean, geom = "point", shape =21, size = 3, colour = "black", fill="yellow")
library("gridExtra")
## Warning: package 'gridExtra' was built under R version 4.4.2
grid.arrange(Shanon.habitat, Simp.habitat, InvSimp.habitat, Fish.habitat,
             nrow=2, ncol=2) 

grid.arrange(Shanon.habitat, Simp.habitat, InvSimp.habitat, Fish.habitat, nrow=2, ncol=2)

shannon_aov <- aov(Ohio.env.Div$shannon ~ Ohio.env.Div$Habitat)

summary(shannon_aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)  
## Ohio.env.Div$Habitat   2   1.66  0.8308   3.335 0.0375 *
## Residuals            207  51.57  0.2491                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
simpson_aov <- aov(Ohio.env.Div$simpson ~ Ohio.env.Div$Habitat)

summary(simpson_aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)  
## Ohio.env.Div$Habitat   2  0.189 0.09426   3.015 0.0512 .
## Residuals            207  6.471 0.03126                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
inv.simpson_aov <- aov(Ohio.env.Div$inv.simpson ~ Ohio.env.Div$Habitat)

summary(inv.simpson_aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## Ohio.env.Div$Habitat   2   18.2   9.109   1.481   0.23
## Residuals            207 1273.6   6.153
fish.alp_aov <- aov(Ohio.env.Div$fish.alp ~ Ohio.env.Div$Habitat)

summary(fish.alp_aov)
##                       Df Sum Sq Mean Sq F value Pr(>F)
## Ohio.env.Div$Habitat   2   15.4   7.687   2.206  0.113
## Residuals            207  721.4   3.485
distance_matrix<-vegdist(Ohio.env.Div[,10:10], method="bray", binary=FALSE)
adonis2(distance_matrix ~ Habitat, data=Ohio.env.Div)
shannon_Tukey<-TukeyHSD(shannon_aov, conf.level=.95, ordered = TRUE)
shannon_Tukey
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
##     factor levels have been ordered
## 
## Fit: aov(formula = Ohio.env.Div$shannon ~ Ohio.env.Div$Habitat)
## 
## $`Ohio.env.Div$Habitat`
##                           diff          lwr       upr     p adj
## wet-mesic-dry-oak   0.14147731 -0.058161073 0.3411157 0.2180524
## dry-mesic-dry-oak   0.20188576  0.007587024 0.3961845 0.0396316
## dry-mesic-wet-mesic 0.06040845 -0.159546381 0.2803633 0.7935133
simpson_Tukey<-TukeyHSD(simpson_aov, conf.level=.95, ordered = TRUE)
simpson_Tukey
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
##     factor levels have been ordered
## 
## Fit: aov(formula = Ohio.env.Div$simpson ~ Ohio.env.Div$Habitat)
## 
## $`Ohio.env.Div$Habitat`
##                           diff           lwr       upr     p adj
## wet-mesic-dry-oak   0.04373077 -0.0269916799 0.1144532 0.3125264
## dry-mesic-dry-oak   0.06936909  0.0005382234 0.1382000 0.0477573
## dry-mesic-wet-mesic 0.02563832 -0.0522812927 0.1035579 0.7177126
inv.simpson_Tukey<-TukeyHSD(inv.simpson_aov, conf.level=.95, ordered = TRUE)
inv.simpson_Tukey 
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
##     factor levels have been ordered
## 
## Fit: aov(formula = Ohio.env.Div$inv.simpson ~ Ohio.env.Div$Habitat)
## 
## $`Ohio.env.Div$Habitat`
##                           diff        lwr      upr     p adj
## wet-mesic-dry-oak   0.06042921 -0.9317123 1.052571 0.9886676
## dry-mesic-dry-oak   0.67188001 -0.2937251 1.637485 0.2301703
## dry-mesic-wet-mesic 0.61145080 -0.4816572 1.704559 0.3853924
fish.alp_Tukey<-TukeyHSD(fish.alp_aov, conf.level=.95, ordered = TRUE)
fish.alp_Tukey
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
##     factor levels have been ordered
## 
## Fit: aov(formula = Ohio.env.Div$fish.alp ~ Ohio.env.Div$Habitat)
## 
## $`Ohio.env.Div$Habitat`
##                            diff        lwr       upr     p adj
## wet-mesic-dry-oak   0.538910024 -0.2077869 1.2856069 0.2061985
## dry-mesic-dry-oak   0.547843742 -0.1788816 1.2745691 0.1789658
## dry-mesic-wet-mesic 0.008933717 -0.8137517 0.8316192 0.9996378
shannon_Tukey_plot <- as.data.frame(shannon_Tukey$`Ohio.env.Div$Habitat`)

shannon_Tukey_plot$comparison <- rownames(shannon_Tukey_plot)

shannon_Tukey_plot
simpson_Tukey_plot <- as.data.frame(simpson_Tukey$`Ohio.env.Div$Habitat`)

simpson_Tukey_plot$comparison <- rownames(simpson_Tukey_plot)

simpson_Tukey_plot
inv.simpson_Tukey_plot <- as.data.frame(inv.simpson_Tukey$`Ohio.env.Div$Habitat`)

inv.simpson_Tukey_plot$comparison <- rownames(inv.simpson_Tukey_plot)

inv.simpson_Tukey_plot
fish.alp_Tukey_plot <- as.data.frame(fish.alp_Tukey$`Ohio.env.Div$Habitat`)

fish.alp_Tukey_plot$comparison <- rownames(fish.alp_Tukey_plot)

fish.alp_Tukey_plot
shannon_Tukey_plot_result<-ggplot(shannon_Tukey_plot, aes(x = comparison, y = diff)) +
  geom_point() +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(
    title = "Tukey HSD Test Results for Shannon Diversity",
    x = "Habitat Comparison",
    y = "Pairwise Difference in Mean"
  )

shannon_Tukey_plot_result

shannon_Tukey_plot_result_meandiff<-shannon_Tukey_plot_result + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  geom_hline(yintercept=0, linetype="dashed", color = "red")

shannon_Tukey_plot_result_meandiff

simpson_Tukey_plot_result<-ggplot(simpson_Tukey_plot, aes(x = comparison, y = diff)) +
  geom_point() +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(
    title = "Tukey HSD Test Results for Simpson Diversity",
    x = "Habitat Comparison",
    y = "Pairwise Difference in Mean"
  )

simpson_Tukey_plot_result

simpson_Tukey_plot_result_meandiff<-simpson_Tukey_plot_result + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  geom_hline(yintercept=0, linetype="dashed", color = "red")

simpson_Tukey_plot_result_meandiff

inv.simpson_Tukey_plot_result<-ggplot(inv.simpson_Tukey_plot, aes(x = comparison, y = diff)) +
  geom_point() +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(
    title = "Tukey HSD Test Results for inv.Simpson Diversity",
    x = "Habitat Comparison",
    y = "Pairwise Difference in Mean"
  )

inv.simpson_Tukey_plot_result

inv.simpson_Tukey_plot_result_meandiff<-inv.simpson_Tukey_plot_result + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  geom_hline(yintercept=0, linetype="dashed", color = "red")

inv.simpson_Tukey_plot_result_meandiff

fish.alp_Tukey_plot_result<-ggplot(fish.alp_Tukey_plot, aes(x = comparison, y = diff)) +
  geom_point() +
  geom_errorbar(aes(ymin = lwr, ymax = upr), width = 0.2) +
  labs(
    title = "Tukey HSD Test Results for fish alpha Diversity",
    x = "Habitat Comparison",
    y = "Pairwise Difference in Mean"
  )

fish.alp_Tukey_plot_result

fish.alp_Tukey_plot_result_meandiff<-fish.alp_Tukey_plot_result + 
  theme(axis.text.x = element_text(angle = 45, hjust = 1)) + 
  geom_hline(yintercept=0, linetype="dashed", color = "red")

fish.alp_Tukey_plot_result_meandiff

grid.arrange(shannon_Tukey_plot_result_meandiff,Shanon.habitat,nrow=1, ncol=2)

grid.arrange(simpson_Tukey_plot_result_meandiff,Simp.habitat,nrow=1, ncol=2)

grid.arrange(inv.simpson_Tukey_plot_result_meandiff,InvSimp.habitat,nrow=1, ncol=2)

grid.arrange(fish.alp_Tukey_plot_result_meandiff,Fish.habitat,nrow=1, ncol=2)