R Under development (unstable) (2024-04-27 r86487 ucrt) -- "Unsuffered Consequences" Copyright (C) 2024 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > library(ClassDiscovery) Loading required package: cluster Loading required package: oompaBase > suppressWarnings( RNGversion("3.5.3") ) > set.seed(316912) > # simulate datda from three different groups > d1 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) > d2 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) > d3 <- matrix(rnorm(100*10, rnorm(100, 0.5)), nrow=100, ncol=10, byrow=FALSE) > dd <- cbind(d1, d2, d3) > kind <- factor(rep(c('red', 'green', 'blue'), each=10)) > > # perform PCA > spc <- SamplePCA(dd, splitter=kind) > > # plot the results > plot(spc, col=levels(kind)) > > # mark the group centers > x1 <- predict(spc, matrix(apply(d1, 1, mean), ncol=1)) > points(x1[1], x1[2], col='red', cex=2) > x2 <- predict(spc, matrix(apply(d2, 1, mean), ncol=1)) > points(x2[1], x2[2], col='green', cex=2) > x3 <- predict(spc, matrix(apply(d3, 1, mean), ncol=1)) > points(x3[1], x3[2], col='blue', cex=2) > > # check out the variances > screeplot(spc) > > # cleanup > rm(d1, d2, d3, dd,kind, spc, x1, x2, x3) > > > proc.time() user system elapsed 0.21 0.10 0.32