Matrix2list | R Documentation |
Convert matrix to sparse list
Matrix2list(x)
Matrix2listInt(x)
x |
Input matrix |
Within the function, the input matrix is first converted to a dgTMatrix matrix (Matrix package).
A two-element list: List of row numbers (r) and a list of numeric or integer values (x)
Matrix2listInt
convers the values to integers by as.integer
and no checking is performed. Thus, zeros are possible.
Øyvind Langsrud
m = matrix(c(0.5, 1.1, 3.14, 0, 0, 0, 0, 4, 5), 3, 3)
Matrix2list(m)
Matrix2listInt(m)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.