This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
#This RMarkdown file details some of the additional calculations and a correlation matrix #anaysis carried out for the study concerning the six anthropogenic substrate sites.
#Make sure to install the relevant package beforehand…
#install.packages(“Hmisc”) #install.packages(“corrplot”)
#Then load the package…
library(Hmisc)
## Warning: package 'Hmisc' was built under R version 4.4.1
##
## Attaching package: 'Hmisc'
## The following objects are masked from 'package:base':
##
## format.pval, units
library(corrplot)
## Warning: package 'corrplot' was built under R version 4.4.1
## corrplot 0.94 loaded
#To load the datasets that will be used in this RMarkdown file… #Make sure you have this set to your own directory beforehand.
GeochemData <- read.csv("PLANT_CHEMISTRY_MAJOR_AND_TRACE_ELEMENTS_MG_KG.csv",
header = TRUE)
FePData <- read.csv("PLANT_CHEMISTRY_Fe2O3_P2O5_MG_KG.csv",
header = TRUE)
#Having a quick look at the data…
head(GeochemData)
## pH SiO2 Al2O3 Fe2O3 CaO MgO Na2O K2O
## 1 6.070 179027.6 88649.43 18534.78 4431.083 4522.769 667.6712 15274.719
## 2 6.403 226705.9 83621.55 34901.33 2429.949 3377.001 519.2998 18097.222
## 3 7.073 201464.5 93941.94 28116.91 4002.268 4703.680 741.8569 16685.970
## 4 6.620 189311.1 84680.05 38468.40 3716.392 4341.858 593.4855 15191.704
## 5 6.633 173418.4 85738.56 18115.12 4145.206 4281.555 667.6712 15772.808
## 6 5.046 118728.5 53983.53 39237.77 5503.119 3859.430 1557.8995 6724.197
## Cr2O3 TiO2 MnO P2O5 SrO BaO LOI Ag As B Be
## 1 82.10429 4015.597 387.2287 1099.8580 169.11891 358.2605 37.9 0.15 8 10 1.4
## 2 75.26227 5454.020 1006.7947 999.8709 84.55946 447.8257 24.5 0.15 5 5 1.1
## 3 88.94632 4614.940 929.3490 1199.8451 84.55946 358.2605 30.4 0.15 3 5 1.4
## 4 82.10429 4375.203 697.0117 1499.8063 84.55946 358.2605 32.4 0.15 8 10 1.4
## 5 75.26227 3955.663 387.2287 1399.8192 169.11891 358.2605 39.5 0.20 5 10 1.6
## 6 82.10429 3236.452 1084.2405 3899.4964 84.55946 268.6954 54.8 0.20 26 10 1.5
## Bi Cd Co Cu Ga Hg La Li Mo Ni Pb S Sb Sc Th Tl U V W Zn
## 1 1.5 0.25 20 51 5 0.5 10 10 1.0 29 42 800 1.5 2 10 5 5 11 5 57
## 2 1.5 0.25 28 44 5 0.5 20 5 1.0 31 50 800 1.5 3 10 5 5 8 5 53
## 3 1.5 0.25 23 48 5 0.5 10 10 0.5 32 51 600 1.5 3 10 5 5 15 5 44
## 4 1.5 0.25 24 44 5 0.5 10 10 1.0 35 45 900 1.5 4 10 5 5 18 5 61
## 5 1.5 0.25 31 65 5 0.5 10 10 1.0 35 69 800 1.5 2 10 5 5 10 5 54
## 6 1.5 0.90 20 87 10 0.5 20 10 4.0 52 148 1600 3.0 3 10 5 5 55 5 221
#I will calculate various statistics that can be referred to for the Renyi biodiversity #analyses, analysed in a separate file. This can help inform us about the varying #concentations of readily bioavailable elements on the different study sites.
#Firstly, to report various calculations for Cd:
min(GeochemData$Cd)
## [1] 0
mean(GeochemData$Cd)
## [1] 0.552439
median(GeochemData$Cd)
## [1] 0.25
max(GeochemData$Cd)
## [1] 2.7
sd(GeochemData$Cd)
## [1] 0.5369999
#Then to report calculations for B:
min(GeochemData$B)
## [1] 0
mean(GeochemData$B)
## [1] 21.21951
median(GeochemData$B)
## [1] 10
max(GeochemData$B)
## [1] 70
sd(GeochemData$B)
## [1] 18.93345
#Then to report calculations for Zn:
min(GeochemData$Zn)
## [1] 24
mean(GeochemData$Zn)
## [1] 329.4634
median(GeochemData$Zn)
## [1] 88
max(GeochemData$Zn)
## [1] 6000
sd(GeochemData$Zn)
## [1] 961.2778
Then to report calculations for Mo:
min(GeochemData$Mo)
## [1] 0
mean(GeochemData$Mo)
## [1] 1.02439
median(GeochemData$Mo)
## [1] 1
max(GeochemData$Mo)
## [1] 4
sd(GeochemData$Mo)
## [1] 0.9079594
Then to report calculations for Hg:
min(GeochemData$Hg)
## [1] 0
mean(GeochemData$Hg)
## [1] 0.5609756
median(GeochemData$Hg)
## [1] 0.5
max(GeochemData$Hg)
## [1] 2
sd(GeochemData$Hg)
## [1] 0.2998984
Then to report calculations for Cu:
min(GeochemData$Cu)
## [1] 0
mean(GeochemData$Cu)
## [1] 36.80488
median(GeochemData$Cu)
## [1] 32
max(GeochemData$Cu)
## [1] 97
sd(GeochemData$Cu)
## [1] 22.74997
Then to report calculations for Pb:
min(GeochemData$Pb)
## [1] 0
mean(GeochemData$Pb)
## [1] 72.26829
median(GeochemData$Pb)
## [1] 56
max(GeochemData$Pb)
## [1] 240
sd(GeochemData$Pb)
## [1] 57.52175
Then to report calculations for SrO:
min(GeochemData$SrO)
## [1] 42.27973
mean(GeochemData$SrO)
## [1] 175.0999
median(GeochemData$SrO)
## [1] 169.1189
max(GeochemData$SrO)
## [1] 676.4756
sd(GeochemData$SrO)
## [1] 116.9437
Then to report calculations for Ag:
min(GeochemData$Ag)
## [1] 0
mean(GeochemData$Ag)
## [1] 0.3
median(GeochemData$Ag)
## [1] 0.2
max(GeochemData$Ag)
## [1] 1.3
sd(GeochemData$Ag)
## [1] 0.2405722
Then to report calculations for As:
min(GeochemData$As)
## [1] 0
mean(GeochemData$As)
## [1] 11.78049
median(GeochemData$As)
## [1] 8
max(GeochemData$As)
## [1] 60
sd(GeochemData$As)
## [1] 12.7014
Then to report calculations for Co:
min(GeochemData$Co)
## [1] 0
mean(GeochemData$Co)
## [1] 11.04878
median(GeochemData$Co)
## [1] 8
max(GeochemData$Co)
## [1] 36
sd(GeochemData$Co)
## [1] 10.01736
###Making a correlation matrix for Fe and P###
# ++++++++++++++++++++++++++++
# flattenCorrMatrix
# ++++++++++++++++++++++++++++
# cormat : matrix of the correlation coefficients
# pmat : matrix of the correlation p-values
flattenCorrMatrix <- function(cormat, pmat) {
ut <- upper.tri(cormat)
data.frame(
row = rownames(cormat)[row(cormat)[ut]],
column = rownames(cormat)[col(cormat)[ut]],
cor =(cormat)[ut],
p = pmat[ut]
)
}
MatrixFePData <- rcorr(as.matrix(FePData[2:3]))
flattenCorrMatrix(MatrixFePData$r, MatrixFePData$P)
## row column cor p
## 1 Fe2O3 P2O5 0.2521914 0.1116757
print(MatrixFePData)
## Fe2O3 P2O5
## Fe2O3 1.00 0.25
## P2O5 0.25 1.00
##
## n= 41
##
##
## P
## Fe2O3 P2O5
## Fe2O3 0.1117
## P2O5 0.1117
#As can be seen from the results here, the low cor values and the high p values generated #demonstrate that there is no statistically significant correlation between Fe and P #throughout the study sites.
sapply(FePData, class)
## Community Fe2O3 P2O5
## "character" "numeric" "numeric"
FePDataMatrix <- data.matrix(FePData, rownames.force = NA)
corrplot(FePDataMatrix, is.corr= FALSE, method= "square")
corrplot(FePDataMatrix, is.corr= FALSE, method = 'number')
corrplot(FePDataMatrix, is.corr= FALSE)
##It can be seen from the p value generated in the correlation matrix, as well as the plots #generated, that there is no statistically significant correlation between Fe2O3 #and P2O5 on the study sites.