I'm basically computing the PCA for a set of variables and everything works fine. Lets say I'm using the iris data as an example, but my data is different. The iris data should be sufficient to explain my question:
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)
When I get the plot, some groups are plotted too close together so I want to make a new plot for this subset of groups (without computing a new PCA for the subset).
Is there a way to make a subset of the ir.pca
object to select only specific groups
to plot?