## Warning: package 'factoextra' was built under R version 4.1.1
## Loading required package: ggplot2
## Warning: package 'ggplot2' was built under R version 4.1.1
## Welcome! Want to learn more? See two factoextra-related books at https://goo.gl/ve3WBa
Triển khai mô hình PCA
Xuất dữ liệu về phương sai của các thành phần chính
## eigenvalue variance.percent cumulative.variance.percent
## Dim.1 7.302028 14.042361 14.04236
## Dim.2 4.150468 7.981669 22.02403
## Dim.3 3.168974 6.094180 28.11821
## Dim.4 2.627944 5.053739 33.17195
## Dim.5 2.374756 4.566839 37.73879
## Dim.6 2.168503 4.170198 41.90899
## Dim.7 1.994919 3.836383 45.74537
## Dim.8 1.973209 3.794632 49.54000
## Dim.9 1.881935 3.619106 53.15911
## Dim.10 1.750493 3.366333 56.52544
## [ reached 'max' / getOption("max.print") -- omitted 42 rows ]
screeplot
fviz_eig(pca, ylim = c(0,30), xlim = c(1,10))

Scoreplot
fviz_pca_ind(pca, label="all", habillage=dat2$Group)+xlim(-10, 10) + ylim (-7.5, 7.5)+labs(title= "PCA scoreplot",x="PC1 (14%)", y = "PC2 (8%)")

Loading plot
fviz_pca_var(pca, geom = c("point", "text"),col.var="contrib")+scale_color_gradient2(low="green", mid="red",high="blue", midpoint=2)+ theme_minimal()

Biplot
fviz_pca_biplot(pca, label="all",title = "PCA - Biplot",geom.var = c("arrow", "text"),geom.ind = c("point", "text"),habillage=dat2$Group)
