sizeDiss               package:cluster               R Documentation

_S_a_m_p_l_e _S_i_z_e _o_f _D_i_s_s_i_m_i_l_a_r_i_t_y _L_i_k_e _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Returns the number of observations (_sample size_) corresponding
     to a  dissimilarity like object, or equivalently, the number of
     rows or columns of a matrix when only the lower or upper
     triangular part (without diagonal) is given.

     It is nothing else but the inverse function of f(n) = n(n-1)/2.

_U_s_a_g_e:

     sizeDiss(d)

_A_r_g_u_m_e_n_t_s:

       d: any R object with length (typically) n(n-1)/2.

_V_a_l_u_e:

     a number; n if 'length(d) == n(n-1)/2', 'NA' otherwise.

_S_e_e _A_l_s_o:

     'dissimilarity.object' and also 'as.dist' for class
     'dissimilarity' and 'dist' objects which have a 'Size' attribute.

_E_x_a_m_p_l_e_s:

     sizeDiss(1:10)# 5, since 10 == 5 * (5 - 1) / 2
     sizeDiss(1:9) # NA

     n <- 1:100
     stopifnot(n == sapply( n*(n-1)/2, function(n) sizeDiss(logical(n))))

