inla.as.sparse.RdConvert a matrix or sparse matrix into the sparse format used by INLA (dgTMatrix)
inla.as.sparse(...)
inla.as.dgTMatrix(A, unique = TRUE, na.rm = FALSE, zeros.rm = FALSE)The arguments. The matrix or sparse matrix, and the additonal arguments
The matrix
Logical. If TRUE, then ensure that the internal representation is unique and
there are no duplicated entries.
(Do not change this unless you know what you are doing.)
Replace NA's in the matrix with zeros.
Remove zeros in the matrix.
inla.as.sparse and inla.as.dgTMatrix is the same function.
The returned value is a sparse matrix in the dgTMatrix-format.
A = matrix(1:9, 3, 3)
inla.as.sparse(A)
#> 3 x 3 sparse Matrix of class "dgTMatrix"
#>
#> [1,] 1 4 7
#> [2,] 2 5 8
#> [3,] 3 6 9