R: CSR Matrices Slicing

slice {rsparse} | R Documentation

## CSR Matrices Slicing

### Description

natively slice CSR matrices without converting them to triplet/CSC

### Usage

    ## S4 method for signature 'RsparseMatrix,index,index,logical'
    x[i, j, drop = TRUE]

    ## S4 method for signature 'RsparseMatrix,missing,index,logical'
    x[i, j, drop = TRUE]

    ## S4 method for signature 'RsparseMatrix,index,missing,logical'
    x[i, j, drop = TRUE]

    ## S4 method for signature 'RsparseMatrix,missing,missing,logical'
    x[i, j, drop = TRUE]

### Arguments

`x` | input `RsparseMatrix`
`i` | row indices to subset
`j` | column indices to subset
`drop` | whether to simplify 1d matrix to a vector

### Value

A `RsparseMatrix`

### Examples

    library(Matrix)
    library(rsparse)
    # dgCMatrix - CSC
    m = rsparsematrix(20, 20, 0.1)
    # make CSR
    m = as(m, "RsparseMatrix")
    inherits(m[1:2, ], "RsparseMatrix")
    inherits(m[1:2, 3:4], "RsparseMatrix")

[Package rsparse version 0.3.3.4 Index]