dado<-read.table("abiotic.txt", header=T)
dados<-dado[1:9,1:11]
library(BBmisc)
## Warning: package 'BBmisc' was built under R version 4.1.3
##
## Attaching package: 'BBmisc'
## The following object is masked from 'package:base':
##
## isFALSE
dadosn<-normalize(dados, method = "standardize", range = c(0, 1), margin = 1L, on.constant = "quiet")
acp = prcomp(dadosn, scale. = TRUE)
acp$sdev
## [1] 2.689815e+00 1.462995e+00 8.424529e-01 6.863167e-01 5.263066e-01
## [6] 3.374318e-01 2.065023e-01 1.013838e-01 9.084394e-17
biplot(acp)

library(factoextra)
## Warning: package 'factoextra' was built under R version 4.1.3
## Carregando pacotes exigidos: ggplot2
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
autovalores <- get_eigenvalue(acp)
fviz_eig(acp)

library(ggplot2)
scores = as.data.frame(acp$x)
ggplot(data = scores, aes(x = PC1, y = PC2, label = rownames(scores))) +
geom_hline(yintercept = 0, colour = "gray65") +
geom_vline(xintercept = 0, colour = "gray65") +
geom_text(colour = "blue", alpha = 0.8, size = 4) +
ggtitle("ACP Abióticos ")

fviz_pca_ind(acp, col.ind = "cos2", gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),repel = TRUE)

fviz_pca_var(acp, col.var = "contrib", #contribuições por cor dos components principais
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE)

fviz_pca_biplot(acp, repel = TRUE,col.var = "#2E9FDF", # Variables color
col.ind = "#696969")

library(FactoMineR)
## Warning: package 'FactoMineR' was built under R version 4.1.3
acp = PCA(dados, graph = FALSE)
acp$eig
## eigenvalue percentage of variance cumulative percentage of variance
## comp 1 7.23510591 65.77369011 65.77369
## comp 2 2.14035579 19.45777992 85.23147
## comp 3 0.70972693 6.45206298 91.68353
## comp 4 0.47103067 4.28209699 95.96563
## comp 5 0.27699859 2.51816901 98.48380
## comp 6 0.11386024 1.03509307 99.51889
## comp 7 0.04264319 0.38766533 99.90656
## comp 8 0.01027868 0.09344258 100.00000
acp$var$coord
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5
## Temp 0.7701171 -0.60828351 0.10030936 0.129307044 -0.062657245
## O2Diss 0.8584157 -0.03063634 -0.44341993 -0.218783036 0.090719855
## Salinity -0.1733582 0.80426480 -0.41385035 0.372284354 0.048689907
## Silt 0.9008554 0.37971882 0.09522892 0.008060893 -0.171132609
## Coarse_Silt 0.9008554 0.37971882 0.09522892 0.008060893 -0.171132609
## Very_Fine_Sand 0.7182238 0.60686781 0.21574925 0.049373618 0.114993166
## AMBI_mean 0.7354716 0.48740243 0.26501379 -0.313374310 0.085195107
## HMWPAH 0.9261332 -0.25054080 0.03301055 0.235354338 -0.109226100
## LMWPAH 0.9432798 -0.25117193 -0.06189549 0.162548255 -0.098286501
## MO 0.8440734 -0.27009151 0.11818513 0.184694608 0.402253247
## Ph -0.8574911 0.17186226 0.42186017 0.226167713 0.004385774
head(acp$ind$coord)
## Dim.1 Dim.2 Dim.3 Dim.4 Dim.5
## GST1 -3.576990 -0.8412115 -0.9368873 0.4371310 -0.3981612
## GST2 -2.562439 -1.5103166 -0.2560303 0.6091699 0.9227323
## GST3 -2.311228 -1.0876226 0.6294350 -0.5496087 -0.9138723
## PST1 2.518776 1.5371595 -1.5084496 -0.1808287 -0.3593646
## PST2 1.872129 -0.4620754 -0.6002463 -1.0686892 0.6179028
## PST3 5.374780 -2.0560652 0.5291509 0.6753323 -0.2460057
library(ade4)
## Warning: package 'ade4' was built under R version 4.1.3
##
## Attaching package: 'ade4'
## The following object is masked from 'package:FactoMineR':
##
## reconst
acp = dudi.pca(dados, nf = 5, scannf = FALSE)
acp$eig
## [1] 7.23510591 2.14035579 0.70972693 0.47103067 0.27699859 0.11386024 0.04264319
## [8] 0.01027868
acp$c1
## CS1 CS2 CS3 CS4 CS5
## Temp 0.28630854 0.41577948 0.11906821 -0.18840724 0.119050855
## O2Diss 0.31913556 0.02094083 -0.52634387 0.31877852 -0.172370749
## Salinity -0.06444984 -0.54973840 -0.49124448 -0.54243811 -0.092512445
## Silt 0.33491348 -0.25954887 0.11303768 -0.01174515 0.325157661
## Coarse_Silt 0.33491348 -0.25954887 0.11303768 -0.01174515 0.325157661
## Very_Fine_Sand 0.26701605 -0.41481181 0.25609651 -0.07193999 -0.218490849
## AMBI_mean 0.27342830 -0.33315375 0.31457400 0.45660304 -0.161873544
## HMWPAH 0.34431108 0.17125193 0.03918385 -0.34292379 0.207533231
## LMWPAH 0.35068572 0.17168332 -0.07347057 -0.23684145 0.186747629
## MO 0.31380348 0.18461541 0.14028693 -0.26910987 -0.764294578
## Ph -0.31879182 -0.11747286 0.50075221 -0.32953839 -0.008333117
acp$co
## Comp1 Comp2 Comp3 Comp4 Comp5
## Temp 0.7701171 0.60828351 0.10030936 -0.129307044 0.062657245
## O2Diss 0.8584157 0.03063634 -0.44341993 0.218783036 -0.090719855
## Salinity -0.1733582 -0.80426480 -0.41385035 -0.372284354 -0.048689907
## Silt 0.9008554 -0.37971882 0.09522892 -0.008060893 0.171132609
## Coarse_Silt 0.9008554 -0.37971882 0.09522892 -0.008060893 0.171132609
## Very_Fine_Sand 0.7182238 -0.60686781 0.21574925 -0.049373618 -0.114993166
## AMBI_mean 0.7354716 -0.48740243 0.26501379 0.313374310 -0.085195107
## HMWPAH 0.9261332 0.25054080 0.03301055 -0.235354338 0.109226100
## LMWPAH 0.9432798 0.25117193 -0.06189549 -0.162548255 0.098286501
## MO 0.8440734 0.27009151 0.11818513 -0.184694608 -0.402253247
## Ph -0.8574911 -0.17186226 0.42186017 -0.226167713 -0.004385774
head(acp$li)
## Axis1 Axis2 Axis3 Axis4 Axis5
## GST1 -3.576990 0.8412115 -0.9368873 -0.4371310 0.3981612
## GST2 -2.562439 1.5103166 -0.2560303 -0.6091699 -0.9227323
## GST3 -2.311228 1.0876226 0.6294350 0.5496087 0.9138723
## PST1 2.518776 -1.5371595 -1.5084496 0.1808287 0.3593646
## PST2 1.872129 0.4620754 -0.6002463 1.0686892 -0.6179028
## PST3 5.374780 2.0560652 0.5291509 -0.6753323 0.2460057
graf<-data.frame(acp$li)
plot(graf$Axis1,graf$Axis2,pch=16, xlab="Componente Principal1", ylab="Componente Principal2", cex.lab=1.5, cex.axis=1.2,cex=1.5, labels=TRUE)
## Warning in plot.window(...): "labels" não é um parâmetro gráfico
## Warning in plot.xy(xy, type, ...): "labels" não é um parâmetro gráfico
## Warning in box(...): "labels" não é um parâmetro gráfico
## Warning in title(...): "labels" não é um parâmetro gráfico
