[R] k- means cluster analysis

ripley@stats.ox.ac.uk ripley at stats.ox.ac.uk
Thu Feb 13 07:47:03 CET 2003

On Wed, 12 Feb 2003, Sundar Dorai-Raj wrote:

> Ngayee J Law wrote:
> > Hi all,
> > 
> > I am trying to run the k-means cluster analysis using the function kmeans
> > in the package cluster.

I think it's the one in package mva.


> However, choosing bad starting values could cause kmeans to crash, as in:
> kmeans(x, centers = c(0, 0))

Really?  That does not crash here, but correctly reports an error message:

> kmeans(x, c(0,0))
Error in switch(Z$ifault, stop("empty cluster: try a better set of initial 
centers"),  : 
        empty cluster: try a better set of initial centers

If you actually have a crash, please report to R-bugs.

There is an increasing trend for people to describe informative error 
messages describing their errors as `crashes', but that is confusing at 

Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

More information about the R-help mailing list