3

我将数据集分为 4 组:groups = taxabylevel。我运行 ggbiplot 并在每个组周围添加椭圆。如何添加每个椭圆的中心?

g <- ggbiplot(pca, obs.scale = 1, var.scale = 1, alpha=0, groups = taxaBylevel,show_guide = FALSE, ellipse = TRUE)
print(g)

在此处输入图像描述

4

1 回答 1

1
data(iris)

pca<-prcomp(iris[,1:4],scale=T)


g<-ggbiplot(pca, obs.scale = 1, var.scale = 1, alpha=0, groups = iris[,5],show_guide = FALSE, ellipse = TRUE)


gmean=aggregate(g$data[,1:2],list(group=g$data$group),mean)

ggbiplot(pca, obs.scale = 1, var.scale = 1, alpha=0, groups = iris[,5],show_guide = FALSE, ellipse = TRUE)+
  geom_point(data=gmean,aes(group=group,colour=group))

在此处输入图像描述

于 2017-04-24T06:58:19.823 回答