> From: msck9 at mizzou.edu
>
> Hi,
> I am new here.
> I used y<-kmeans(x, 2)(x is a vector) to do the cluster
> analysis. I get
> y has $cluster, $center etc. I need to pull out the data belong to
> cluster 1 and cluster 2. How can I do that?
Here's an example:
> cl <- round(runif(20))
> x <- rnorm(20, mean=cl)
> km <- kmeans(x, 2)
> x[km$cluster == 1]
[1] -1.739624361 -0.046792299 -0.309680321 0.001928340 -1.036573237
-1.875550649
[7] -2.276369358 -0.453359967 -1.500753548 -1.864152516> x[km$cluster == 2]
[1] 0.6467709 1.9746519 1.9463621 2.9971197 2.8290800 0.8533460 0.6175901
2.2296458
[9] 0.6616395 1.5822679
Andy
> Thanks,
> Ming
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide!
> http://www.R-project.org/posting-guide.html
>
>