[R] mva - kmeans (repetitive requests)

Athula Herath Athula.Herath at ogs.co.uk
Mon Dec 18 14:08:20 CET 2000


Hi All,

Should I get two different results if I were to repeat the kmeans
clustering on the same data set?


R : Copyright 2000, The R Development Core Team
Version 1.1.1  (August 15, 2000)


The following code

library(mva)
data(iris)
kmeans(iris[1:4],5,20)

generates:

$cluster
  [1] 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5
5 5 5 5
 [38] 5 5 5 5 5 5 5 5 5 5 5 5 5 2 2 2 3 2 3 2 4 2 3 4 3 3 2 3 2 3 3 2 3
2 3 2 2
 [75] 2 2 2 2 2 3 3 3 3 2 3 2 2 2 3 3 3 2 3 4 3 3 3 2 4 3 1 2 1 1 1 1 3
1 1 1 2
[112] 2 1 2 2 1 1 1 1 2 1 2 1 2 1 1 2 2 1 1 1 1 1 2 2 1 1 1 2 1 1 1 2 1
1 1 2 2
[149] 1 2

$centers
  Sepal.Length Sepal.Width Petal.Length Petal.Width
1     6.912500    3.100000     5.846875     2.13125
2     6.252500    2.855000     4.815000     1.62500
3     5.620833    2.691667     4.075000     1.26250
4     5.000000    2.300000     3.275000     1.02500
5     5.006000    3.428000     1.462000     0.24600

$withinss
[1] 18.703437 13.624750  5.219167  0.295000 15.151000

$size
[1] 32 40 24  4 50

And if I do a further  kmeans(iris[1:4],5,20) gives me:

$cluster
  [1] 5 1 1 1 5 5 1 5 1 1 5 1 1 1 5 5 5 5 5 5 5 5 1 5 1 1 5 5 5 1 1 5 5
5 1 1 5
 [38] 5 1 5 5 1 1 5 5 1 5 1 5 1 2 2 2 3 2 3 2 3 2 3 3 3 3 2 3 2 3 3 2 3
2 3 2 2
 [75] 2 2 2 2 2 3 3 3 3 2 3 2 2 2 3 3 3 2 3 3 3 3 3 2 3 3 4 2 4 2 4 4 3
4 4 4 2
[112] 2 4 2 2 4 4 4 4 2 4 2 4 2 4 4 2 2 4 4 4 4 4 2 2 4 4 2 2 4 4 4 2 4
4 4 2 2
[149] 4 2

$centers
  Sepal.Length Sepal.Width Petal.Length Petal.Width
1     4.704545    3.122727     1.413636   0.2000000
2     6.257143    2.861905     4.850000   1.6333333
3     5.532143    2.635714     3.960714   1.2285714
4     6.950000    3.106667     5.866667   2.1533333
5     5.242857    3.667857     1.500000   0.2821429

$withinss
[1]  3.114091 14.800238  9.749286 17.555000  4.630714

$size
[1] 22 42 28 30 28

In S-Plus (2000)  the repetitive executions gives us the same result.
Are these  results  generated by R consistent?

Thanks,

Athula.






**********************************************************************
The information transmitted by this email is private and
confidential and is intended for the use of the intended 
recipients specified therein.
If you are neither an intended recipient nor an employee
or agent responsible for delivery to an intended recipient,
you should be aware that any dissemination, distribution
or copying of this communication is strictly prohibited.
If you have received this communication in error, please
notify us immediately.
**********************************************************************
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list