

   KK--MMeeaannss CClluusstteerriinngg

        kmeans(x, centers, iter.max=10)

   AArrgguummeennttss::

          x: A data frame or matrix of data.

    centers: Either the number of clusters or a set of initial
             cluster centers.  If the first, a random set of
             rows in `x' are chosen as the initial centers.

   iter.max: The maximum number of iterations allowed.

   DDeessccrriippttiioonn::

        The data given by `x' is clustered by the k-Means algo-
        rithm.  This algorithm works by repeatedly moving all
        cluster centers to the mean of their Voronoi sets.

        The algorithm stops, if no cluster center has changed
        during the last iteration or the maximum number of
        iterations (given by `iter.max') is reached.

   VVaalluuee::

        A list with components:

    cluster: A vector of integers indicating the cluster to
             which each point is allocated.

    centers: A matrix of cluster centres.

   withinss: The within-cluster sum of squares for each clus-
             ter.

       size: The number of points in each cluster

   RReeffeerreenncceess::

        Hartigan,  J.A. and Wong, M.A. (1979).  A K-means clus-
        tering algorithm.  Applied Statistics 28, 100-108.

   EExxaammpplleess::

        # a 2-dimensional example
        x<-rbind(matrix(rnorm(100,sd=0.3),ncol=2),
                 matrix(rnorm(100,mean=1,sd=0.3),ncol=2))
        cl<-kmeans(x,2,20)
        plot(x,col=cl$cluster)
        points(cl$centers,col=1:2,pch=8)

