【发布时间】:2016-05-25 16:28:04
【问题描述】:
我基本上是在为一组变量计算 PCA,一切正常。假设我以虹膜数据为例,但我的数据不同。虹膜数据应该足以解释我的问题:
data(iris)
log.ir <- log(iris[, 1:4])
log.ir[mapply(is.infinite, log.ir)] <- 0
ir.groups<- iris[, 5]
ir.pca <- prcomp(log.ir, center = TRUE, scale. = TRUE)
library(ggbiplot)
g <- ggbiplot(ir.pca, obs.scale = 1,var.scale = 1,groups = ir.groups, var.axes=F)
g <- g + scale_color_discrete(name = '')
g <- g + theme(legend.direction = 'horizontal',
legend.position = 'top') + theme(legend.text=element_text(size=15), legend.key.size = unit(2.5, "lines")) + theme(text = element_text(size=20))
ggsave("pca2.pdf", g, width=15, height=15)
当我得到图时,一些组被绘制得太近了,所以我想为这个组子集制作一个新图(而不为子集计算新的 PCA)。
有没有办法让ir.pca 对象的子集只选择特定的groups 进行绘图?
【问题讨论】: