tests/weights.R

library("flexclust")

x <- matrix(runif(1000, 0, 1), ncol=2)

set.seed(1)
cl0 <- kcca(x, k=20)
cl1 <- kcca(x, k=20, weights=x[,1])
cl2 <- kcca(x, k=20, weights=x[,2])

pdf("weights.pdf")
plot(cl0)
plot(cl1)
plot(cl2)

m1 <- colMeans(cl1@centers)
m2 <- colMeans(cl2@centers)

stopifnot(diff(m1)<0)
stopifnot(diff(m2)>0)

Try the flexclust package in your browser

Any scripts or data that you put into this service are public.

flexclust documentation built on April 8, 2022, 5:09 p.m.