4

I have data set seperated in 4 groups: groups = taxabylevel. I ran ggbiplot and add ellipses around each group. How to add centre of each ellipses?

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

enter image description here

r2evans
  • 141,215
  • 6
  • 77
  • 149
Doro
  • 75
  • 5

1 Answers1

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))

enter image description here

J.Con
  • 4,101
  • 4
  • 36
  • 64