reorder                package:stats                R Documentation

_R_e_o_r_d_e_r _a _d_e_n_d_r_o_g_r_a_m

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

     There are many different orderings of a dendrogram that are
     consistent with the structure imposed.  This function takes a
     dendrogram and a vector of values and reorders the dendrogram in
     the order of the supplied vector, maintaining the constraints on
     the dendrogram.

_U_s_a_g_e:

     reorder(x, ...)

     ## S3 method for class 'dendrogram':
     reorder(x, wts, agglo.FUN = sum, ...)

_A_r_g_u_m_e_n_t_s:

       x: the (dendrogram) object to be reordered

     wts: numeric weights (arbitrary values) for reordering.

agglo.FUN: a function for weights agglomeration, see below.

     ...: additional arguments

_D_e_t_a_i_l_s:

     Using the weights 'wts', the leaves of the dendrogram are
     reordered so as to be in an order as consistent as possible with
     the weights.  At each node, the branches are ordered in increasing
     weights where the weight of a branch is defined as f(w_j) where f
     is 'agglo.FUN' and w_j is the weight of the j-th sub branch).

_V_a_l_u_e:

     From 'reorder.dendrogram', a dendrogram where each node has a
     further attribute 'value' with its corresponding weight.

_A_u_t_h_o_r(_s):

     R. Gentleman and M. Maechler

_S_e_e _A_l_s_o:

     'rev.dendrogram' which simply reverses the nodes' order;
     'heatmap', 'cophenetic'.

_E_x_a_m_p_l_e_s:

       set.seed(123)
       x <- rnorm(10)
       hc <- hclust(dist(x))
       dd <- as.dendrogram(hc)
       dd.reorder <- reorder(dd, 10:1)
       plot(dd, main = "random dendrogram `dd'")

       op <- par(mfcol = 1:2)
       plot(dd.reorder, main = "reorder(dd, 10:1)")
       plot(reorder(dd,10:1, agglo.FUN= mean),
            main = "reorder(dd, 10:1, mean)")
       par(op)

