如何在PCA双向图中显示观测结果? [英] How to display observations in pca biplot?
本文介绍了如何在PCA双向图中显示观测结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我希望使用FactoExtra程序包在主成分分析双曲线图上显示观测行名。
library(factoextra)
## organize dataset to obtain unique rownames
iris$id <- rownames(iris)
iris$id <- paste(iris$Species, iris$id, sep="_")
rownames(iris) <- iris$id
iris <- iris[,1:4]
## Run PCA
pca <- prcomp(iris, center=T, scale. = T)
## On this plot observation names are displayed
fviz_pca_ind(pca,
col.ind = "cos2", # Color by the quality of representation
gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
repel = TRUE
)
## Is there any way to display the same row names in this plot? (instead of points)
fviz_pca_biplot(pca,
col.var = "#2E9FDF", # Variables color
col.ind = "#696969", # Individuals color
label = 'var',
repel = TRUE
)
提前谢谢
推荐答案
您可以指定geom.ind=";txt";
fviz_pca_biplot(pca,geom.ind="text",labelsize=2,
col.var = "#2E9FDF",col.ind = "#696969")
并尝试添加ggrepel:
options(ggrepel.max.overlaps = 20)
fviz_pca_biplot(pca,geom.ind="text",labelsize=2,
col.var = "#2E9FDF",col.ind = "#696969",repel=TRUE)
这篇关于如何在PCA双向图中显示观测结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文