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))))

