I am not sure if this can be done within the ggbiplot
call, but it is certainly possible by adding another layer. Here is an example:
library(ggbiplot)
data(wine)
wine.pca <- prcomp(wine, scale. = TRUE)
p <- ggbiplot(wine.pca, obs.scale = 1, var.scale = 1, groups = wine.class,
ellipse = TRUE, circle = TRUE)
now subset the points you would like to highlight:
wine.pca$x[wine$Alcohol == 13.2, 1:2, drop = FALSE] #drop = FALSE to keep matrix class
and provide that as data
to geom_point
:
p + geom_point(data = wine.pca$x[wine$Alcohol == 13.2, 1:2, drop = FALSE],
aes(x = PC1, y = PC2), color = "black")
you can also do something like this:
p + geom_point(data = wine.pca$x[wine$Alcohol == 13.2, 1:2, drop = FALSE],
aes(x = PC1, y = PC2), color = "black", shape = 21, size = 7)
however this might be too much if you want to highlight many points:
p + geom_point(data = wine.pca$x[wine$Alcohol >= 13.2, 1:2],
aes(x = PC1, y = PC2), color = "black", shape = 21, size = 7)