[R] kmeans: how to retrieve clusters

ikuzar razuki at hotmail.fr
Tue Feb 28 00:18:21 CET 2012


Hello,

I'd like to classify data with kmeans algorithm. In my case, I should get  2
clusters in output. Here is my data

colCandInd	 colCandMed
1	82	          2950.5	
2	83	         1831.5
3	1192	 2899.0	
4	1193	 2103.5

The first cluster is the two first lines
the 2nd cluster is the two last lines

Here is the code:
x = colCandList$colCandInd
y = colCandList$colCandMed
m = matrix(c(x, y), nrow = length(colCandList$colCandInd), ncol=2)
kres = kmeans(m, 2)

Is there a way to retrieve both clusters in output of the algorithm in order
to process in each cluster ? (I am looking for smthing like kres$clustList
... where I can process each cluster)

kres$cluster did not yield what I expected ...

thanks for your help


--
View this message in context: http://r.789695.n4.nabble.com/kmeans-how-to-retrieve-clusters-tp4426427p4426427.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list