Re: [R] Using centers of hierarchical clustering for k-means

2014-05-20 Thread marioger
Thank you very much for your help. everything works great -- View this message in context: http://r.789695.n4.nabble.com/Using-centers-of-hierarchical-clustering-for-k-means-tp4690704p4690870.html Sent from the R help mailing list archive at Nabble.com.

Re: [R] Using centers of hierarchical clustering for k-means

2014-05-16 Thread Sarah Goslee
Well, you could use the group membership from the clustering along with, for instance, aggregate() to get the mean values for each cluster, and pass those to kmeans() using the centers argument as described in the help file. Unless you want medoids instead of centroids, since you didn't specify?

Re: [R] Using centers of hierarchical clustering for k-means

2014-05-16 Thread David L Carlson
This should get you started > set.seed(42) > x <- matrix(rnorm(200, 25, 5), 40, 5) > x.clus <- hclust(dist(x)) > x.g4 <- cutree(x.clus, 4) > x.cent <- aggregate(x, list(x.g4), mean) > x.km <- kmeans(x, x.cent[,-1]) > xtabs(~x.g4+x.km$cluster) x.km$cluster x.g4 1 2 3 4 1 10 0 1 0 2