Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- > myMatrix
- a b c
- a . 1 2
- b 1 . .
- c 2 . .
- library(Matrix)
- myMatrix <- sparseMatrix(
- i = c(1,1,2,3),
- j = c(2,3,1,1),
- x = c(1,2,1,2))
- myMatrix
- # 3 x 3 sparse Matrix of class "dgCMatrix"
- #
- # [1,] . 1 2
- # [2,] 1 . .
- # [3,] 2 . .
- mat.summ <- summary(myMatrix)
- lower.summ <- subset(mat.summ, i >= j)
- sparseMatrix(i = lower.summ$i,
- j = lower.summ$j,
- x = lower.summ$x,
- dims = dim(myMatrix))
- # 3 x 3 sparse Matrix of class "dgCMatrix"
- #
- # [1,] . . .
- # [2,] 1 . .
- # [3,] 2 . .
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement