as.hclust               package:stats               R Documentation

_C_o_n_v_e_r_t _O_b_j_e_c_t_s _t_o _C_l_a_s_s _h_c_l_u_s_t

_D_e_s_c_r_i_p_t_i_o_n:

     Converts objects from other hierarchical clustering functions to
     class '"hclust"'.

_U_s_a_g_e:

     as.hclust(x, ...)

_A_r_g_u_m_e_n_t_s:

       x: Hierarchical clustering object

     ...: further arguments passed to or from other methods.

_D_e_t_a_i_l_s:

     Currently there is only support for converting objects of class
     '"twins"' as produced by the functions 'diana' and 'agnes' from
     the package 'cluster'.  The default method throws an error unless
     passed an '"hclust"' object.

_V_a_l_u_e:

     An object of class '"hclust"'.

_S_e_e _A_l_s_o:

     'hclust', 'diana', 'agnes'

_E_x_a_m_p_l_e_s:

     x <- matrix(rnorm(30), ncol=3)
     hc <- hclust(dist(x), method="complete")

     if(require(cluster, quietly=TRUE)) {# is a recommended package
       ag <- agnes(x, method="complete")
       hcag <- as.hclust(ag)
       ## The dendrograms order slightly differently:
       op <- par(mfrow=c(1,2))
       plot(hc) ;  mtext("hclust", side=1)
       plot(hcag); mtext("agnes",  side=1)
     }

