## Generating data with 2 and 3 distinct clusters
## Note that 'clustStruct' returns a list
n=120; k <- c(2,3)
dd <- clustStruct(n=n, p=30, k=k, noiseDat='random')
## Laplacians
L_list <- lapply(dd, kernelLaplacian, kernel="Spectrum", plots=FALSE, verbose=FALSE)
## Calculating the flag mean
fm <- flagMean(L_list, k=k, laplacian='shift')
## Knowing the true structure makes it much easier to know how
## many right singular vectors to grab. There are 4 distinct
## groups in these data from 'clustStruct'
trueGroups(n=n, k=k)
kmeans(fm$u[, 1:4], centers=4)
Run the code above in your browser using DataLab