主成分分析-个体图

Principal component analysis - graph of individuals

我想知道是否可以在图表上只显示选定的组,或者制作一些个人图表,因为在我的 PCA 中我有超过 10 个组并且在一张图表上不清晰。我将在虹膜数据上提出我的问题。

library(ggplot2)
library(factoextra)
data(iris)
res.pca <- prcomp(iris[, -5],  scale = TRUE)
fviz_pca_ind(res.pca, label="none", habillage=iris$Species)

那么,例如,我可以在图表上只显示一组 setos 吗?还是只有山毛榉和云芝?

fviz_pca_ind 支持带有 select.ind 参数的数据子集:

select.ind
a selection of individuals/variables to be drawn. Allowed values are NULL or a list containing the arguments name, cos2 or contrib:

name: is a character vector containing individuals/variables to be drawn
cos2: if cos2 is in [0, 1], ex: 0.6, then individuals/variables with a cos2 > 0.6 are drawn. if cos2 > 1, ex: 5, then the top 5 individuals/variables with the highest cos2 are drawn.
contrib: if contrib > 1, ex: 5, then the top 5 individuals/variables with the highest cos2 are drawn

无法直接指定 setosa,但您可以指定 setosa 行的索引。

setosa_indices <- rownames(iris[iris$Species == "setosa",])

fviz_pca_ind(res.pca, label = "none",
             habillage = iris$Species,
             select.ind = list(name = setosa_indices))

结果: