Learn R Programming

SSBtools (version 1.7.0)

Matrix2list: Convert matrix to sparse list

Description

Convert matrix to sparse list

Usage

Matrix2list(x)

Matrix2listInt(x)

Value

A two-element list: List of row numbers (r) and a list of numeric or integer values (x)

Arguments

x

Input matrix

Author

Øyvind Langsrud

Details

Within the function, the input matrix is first converted to a dgTMatrix matrix (Matrix package).

Examples

Run this code
m = matrix(c(0.5, 1.1, 3.14, 0, 0, 0, 0, 4, 5), 3, 3)
Matrix2list(m)
Matrix2listInt(m)

Run the code above in your browser using DataLab