PCA:如何为样本分发添加名称

时间:2018-04-22 08:10:53

标签: r ggplot2 pca

在样本分布图中,而不是名称(在第一列中给出)中,为季节提供数字1,2,3,4。我有六个专栏(Season Annelida Decapoda Gastropoda Isopoda Pisces)。

    mydata<- read.csv("IRI_diet.csv", TRUE, ",")
mydata[is.na(mydata)]=0
attach(mydata)
X=cbind (Annelida, Decapoda, Gastropoda, Isopoda, Pisces)
summary(X)
cor(X)
res.pca <- prcomp (X, scores=TRUE, cor=TRUE)
summary(res.pca)

fviz_pca_ind(res.pca,
             col.ind = "cos2", # Color by the quality of representation
             gradient.cols = c("#00AFBB", "#E7B800", "#FC4E07"),
             repel = TRUE     # Avoid text overlapping
)

这是情节

enter image description here

1

0 个答案:

没有答案