

kmeans {mva}                                 R Documentation

_K_-_M_e_a_n_s _C_l_u_s_t_e_r_i_n_g

_D_e_s_c_r_i_p_t_i_o_n_:

     Perform k-means clustering on a data matrix.

_U_s_a_g_e_:

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

_A_r_g_u_m_e_n_t_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_e_t_a_i_l_s_:

     The data given by `x' is clustered by the k-Means algo-
     rithm.  When this terminates, all cluster centres are
     at to the mean of their Voronoi sets (the set of data
     points which are nearest to the cluster centre).

     The algorithm of Hartigan and Wong (1979) is used.

_V_a_l_u_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_e_f_e_r_e_n_c_e_s_:

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

_E_x_a_m_p_l_e_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)

