Plot PCA groups from anticlustering result

plotPCAgroups(pca_res, groups, pcs = c(1, 2), filename = NULL)

Arguments

pca_res

A prcomp object.

groups

A factor or vector of group assignments.

pcs

Vector of length 2 indicating which PCs to plot (default: c(1, 2)).

filename

Optional. If provided, saves plot to this file (e.g., "antic.png").

Value

A ggplot object (also prints to screen).

Examples

# \donttest{
set.seed(1)
pca_res <- stats::prcomp(matrix(rnorm(200), nrow = 20))
groups <- sample(1:2, 20, replace = TRUE)
plotPCAgroups(pca_res, groups)

# }