sparseMatrix-class          package:Matrix          R Documentation

_V_i_r_t_u_a_l _C_l_a_s_s "_s_p_a_r_s_e_M_a_t_r_i_x" - _M_o_t_h_e_r _o_f _S_p_a_r_s_e _M_a_t_r_i_c_e_s

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

     Virtual Mother Class of All Sparse Matrices

_S_l_o_t_s:

     '_D_i_m': Object of class '"integer"' - the dimensions of the matrix
          - must be an integer vector with exactly two non-negative
          values.

     '_D_i_m_n_a_m_e_s': a list of length two - inherited from class 'Matrix',
          see 'Matrix'.

     '_f_a_c_t_o_r_s': Object of class '"list"' - a list of factorizations of
          the matrix. 

_E_x_t_e_n_d_s:

     Class '"Matrix"', directly.

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

     _s_h_o_w '(object = "sparseMatrix")': The 'show' method for sparse
          matrices prints _"structural"_ zeroes as '"."' using
          'printSpMatrix()' which allows further customization.

     _p_r_i_n_t 'signature(x = "sparseMatrix")', ....
           The 'print' method for sparse matrices by default is the
          same as 'show()' but can be called with extra optional
          arguments, see 'printSpMatrix()'.

     _s_u_m_m_a_r_y '(object = "sparseMatrix")': Returns an object of S3 class
          '"sparseSummary"' which is basically a 'data.frame' with
          columns '(i,j,x)' with the non-zero entries.   The 'print'
          method resemble's Matlab's way of printing sparse matrices.

     _d_i_a_g '(x = "sparseMatrix")': extracts the diagonal of a sparse
          matrix.

     _d_i_m<- 'signature(x = "sparseMatrix", value = "ANY")': allows to
          _reshape_ a sparse matrix to a sparse matrix with the same
          entries but different dimensions. 'value' must be of length
          two and fulfill 'prod(value) == prod(dim(x))'.

     _c_o_e_r_c_e 'signature(from = "factor", to = "sparseMatrix")': Coercion
          of a factor to '"sparseMatrix"' produces the matrix of
          indicator *rows* stored as an object of class '"dgCMatrix"'. 
          To obtain columns representing the interaction of the factor
          and a numeric covariate, replace the '"x"' slot of the result
          by the numeric covariate then take the transpose.

     See also 'colSums', ...  for methods with separate help pages.

_N_o_t_e:

     In method selection for multiplication operations (i.e. '%*%' and
     the two-argument form of 'crossprod') the sparseMatrix class takes
     precedence in the sense that if one operand is a sparse matrix and
     the other is any type of dense matrix then the dense matrix is
     coerced to a 'dgeMatrix' and the appropriate sparse matrix method
     is used.

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

     showClass("sparseMatrix") ## and look at the help() of its subclasses
     M <- Matrix(0, 10000, 100)
     M[1,1] <- M[2,3] <- 3.14
     M  ## show(.) method suppresses printing of the majority of rows

     ## factor -> t( <sparse design matrix> ) :
     (fact <- gl(5, 3, 30, labels = LETTERS[1:5]))
     (Xt <- as(fact, "sparseMatrix"))  # indicator rows
     X <- t(Xt)

