nonzero-methods            package:Ringo            R Documentation

_M_e_t_h_o_d_s _f_o_r _F_u_n_c_t_i_o_n _n_o_n_z_e_r_o

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

     Auxiliary functions to retrieve the indices of non-zero elements
     in sparse matrices.

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

     A two-column matrix. Each row gives the row and column index of a
     non-zero element in the supplied matrix 'x'.

_M_e_t_h_o_d_s:


     _x = "_d_g_C_M_a_t_r_i_x" returns the indices of non-zero elements in
          matrices of class 'dgCMatrix'

     _x = "_m_a_t_r_i_x._c_s_r" returns the indices of non-zero elements in
          matrices of class 'matrix.csr'

     _x = "_m_a_t_r_i_x" returns the indices of non-zero elements in matrices
          of base class 'matrix'; equivalent to 'which(x != 0,
          arr.ind=TRUE)'

_N_o_t_e:

     Originally we used the 'matrix.csr' class from SparseM, but we
     have switched to the class 'dgCMatrix' from package Matrix, as
     that package is part of the R distribution bundle now.

     The idea is to have a function similar to 'which(x != 0,
     arr.ind=TRUE)' if 'x' is a matrix.

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

     'dgCMatrix-class'

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

       (A <- matrix(c(0,0,0,0,0,1,0,0,0,0,0,0,0,0,-34),
                    nrow=5, byrow=TRUE))
       str(A.dgc <- as(A, "dgCMatrix"))
       nonzero(A.dgc)
       A2.dgc <- Matrix::cBind(A.dgc, A.dgc)
       as.matrix(A2.dgc)
       nonzero(A2.dgc)

