sums                  package:slam                  R Documentation

_F_o_r_m _R_o_w _a_n_d _C_o_l_u_m_n _S_u_m_s _a_n_d _M_e_a_n_s

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

     Form row and column sums and means for sparse arrays (currently
     'simple_triplet_matrix' only).

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

     row_sums(x, na.rm = FALSE, dims = 1, ...)
     col_sums(x, na.rm = FALSE, dims = 1, ...)
     row_means(x, na.rm = FALSE, dims = 1, ...)
     col_means(x, na.rm = FALSE, dims = 1, ...)

     ## S3 method for class 'simple_triplet_matrix':
     row_sums(x, na.rm = FALSE, dims = 1, ...)
     ## S3 method for class 'simple_triplet_matrix':
     col_sums(x, na.rm = FALSE, dims = 1, ...)
     ## S3 method for class 'simple_triplet_matrix':
     row_means(x, na.rm = FALSE, dims = 1, ...)
     ## S3 method for class 'simple_triplet_matrix':
     col_means(x, na.rm = FALSE, dims = 1, ...)

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

       x: a sparse array containing numeric, integer, or logical
          values. 

   na.rm: logical. Should missing values (including 'NaN') be omitted
          from the calculations? 

    dims: currently not used for sparse arrays. 

     ...: currently not used for sparse arrays. 

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

     Provides fast summation over the rows or columns of sparse
     matrices in 'simple_triplet'-form.

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

     A numeric (double) array of suitable size, or a vector if the
     result is one-dimensional. The 'dimnames' (or 'names' for a vector
     result) are taken from the original array.

_N_o_t_e:

     Results are always of storage type 'double' to avoid (integer)
     overflows.

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

     Christian Buchta

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

     'simple_triplet_matrix', 'colSums' for dense numeric arrays.

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

     ##
     x <- matrix(c(1, 0, 0, 2, 1, NA), nrow = 3)
     x
     s <- as.simple_triplet_matrix(x)
     row_sums(s)
     row_sums(s, na.rm = TRUE)
     col_sums(s)
     col_sums(s, na.rm = TRUE)

