rect.hclust              package:stats              R Documentation

_D_r_a_w _R_e_c_t_a_n_g_l_e_s _A_r_o_u_n_d _H_i_e_r_a_r_c_h_i_c_a_l _C_l_u_s_t_e_r_s

_D_e_s_c_r_i_p_t_i_o_n:

     Draws rectangles around the branches of a dendrogram highlighting
     the corresponding clusters. First the dendrogram is cut at a
     certain level, then a rectangle is drawn around selected branches.

_U_s_a_g_e:

     rect.hclust(tree, k = NULL, which = NULL, x = NULL, h = NULL,
                 border = 2, cluster = NULL)

_A_r_g_u_m_e_n_t_s:

    tree: an object of the type produced by 'hclust'.

    k, h: Scalar. Cut the dendrogram such that either exactly 'k'
          clusters are produced or by cutting at height 'h'.

which, x: A vector selecting the clusters around which a rectangle
          should be drawn. 'which' seleccts clusters by number (from
          left to right in the tree), 'x' selects clusters containing
          the respective horizontal coordinates. Default is 'which =
          1:k'.

  border: Vector with border colors for the rectangles.

 cluster: Optional vector with cluster memberships as returned by
          'cutree(hclust.obj, k = k)', can be specified for efficiency
          if already computed.

_V_a_l_u_e:

     (Invisibly) returns a list where each element contains a vector of
     data points contained in the respective cluster.

_S_e_e _A_l_s_o:

     'hclust', 'identify.hclust'.

_E_x_a_m_p_l_e_s:

     hca <- hclust(dist(USArrests))
     plot(hca)
     rect.hclust(hca, k=3, border="red")
     x <- rect.hclust(hca, h=50, which=c(2,7), border=3:4)
     x

