dgTMatrix-class package:Matrix R Documentation _S_p_a_r_s_e _m_a_t_r_i_c_e_s _i_n _t_r_i_p_l_e_t _f_o_r_m _D_e_s_c_r_i_p_t_i_o_n: The '"dgTMatrix"' class is the class of sparse matrices stored as (possibly redundant) triplets. The internal representation is not at all unique, contrary to the one for class 'dgCMatrix'. _O_b_j_e_c_t_s _f_r_o_m _t_h_e _C_l_a_s_s: Objects can be created by calls of the form 'new("dgTMatrix", ...)', but more typically via 'as(*, "dgTMatrix")'. _S_l_o_t_s: '_i': Object of class '"integer"' - the row indices of non-zero entries _in 0-base_, i.e., must be in '0:(nrow(.)-1)'. '_j': Object of class '"integer"' - the column indices of non-zero entries. Must be the same length as slot 'i' and _0-based_ as well, i.e., in '0:(ncol(.)-1)'. '_x': Object of class '"numeric"' - the (non-zero) entry at position '(i,j)'. Must be the same length as slot 'i'. If an index pair occurs more than once the corresponding values of slot 'x' are added to form the element of the matrix. '_D_i_m': Object of class '"integer"' of length 2 - the dimensions of the matrix. _M_e_t_h_o_d_s: + 'signature(e1 = "dgTMatrix", e2 = "dgTMatrix")' _c_o_e_r_c_e 'signature(from = "dgTMatrix", to = "dgCMatrix")' _c_o_e_r_c_e 'signature(from = "dgTMatrix", to = "dgeMatrix")' _c_o_e_r_c_e 'signature(from = "dgTMatrix", to = "matrix")', and typically coercion methods for more specific signatures, we are not mentioning here. Note that these are not guaranteed to continue to exist, but rather you should use calls like 'as(x, "CsparseMatrix")', 'as(x, "generalMatrix")', 'as(x, "dMatrix")', i.e. coercion to higher level virtual classes. _c_o_e_r_c_e 'signature(from = "matrix", to = "dgTMatrix")', (direct coercion from tradition matrix). _c_r_o_s_s_p_r_o_d 'signature(x = "dgTMatrix", y = "missing")' returns 't(x) %*% x' as an 'dsCMatrix' object. _c_r_o_s_s_p_r_o_d 'signature(x = "dgTMatrix", y = "matrix")': ... _c_r_o_s_s_p_r_o_d 'signature(x = "dgTMatrix", y = "numeric")': ... _i_m_a_g_e 'signature(x = "dgTMatrix")': plots an image of 'x' using the 'levelplot' function _t 'signature(x = "dgTMatrix")': returns the transpose of 'x' _N_o_t_e: Triplet matrices are a convenient form in which to construct sparse matrices after which they can be coerced to 'dgCMatrix' objects. _S_e_e _A_l_s_o: Class 'dgCMatrix' or the superclasses 'dsparseMatrix' and 'TsparseMatrix'; _E_x_a_m_p_l_e_s: m <- Matrix(0+1:28, nrow = 4) m[-3,c(2,4:5,7)] <- m[ 3, 1:4] <- m[1:3, 6] <- 0 (mT <- as(m, "dgTMatrix")) str(mT) mT[1,] mT[4, drop = FALSE] stopifnot(identical(mT[lower.tri(mT)], m [lower.tri(m) ])) mT[lower.tri(mT,diag=TRUE)] <- 0 mT