rbind_csr: Concatenate inputs by rows into a CSR matrix

View source: R/rbind.R

rbind_csrR Documentation

Concatenate inputs by rows into a CSR matrix

Description

Concatenate two or more matrices and/or vectors by rows, giving a CSR matrix as result.

This is aimed at concatenating several CSR matrices or sparse vectors at a time, as it will be faster than calling 'rbind' which will only concatenate one at a time, resulting in unnecessary allocations.

Usage

rbind_csr(...)

Arguments

...

Inputs to concatenate. The function is aimed at CSR matrices ('dgRMatrix', 'ngRMatrix', 'lgRMatrix') and sparse vectors ('sparseVector'). It will work with other classes (such as 'dgCMatrix') but will not be as efficient.

Details

This function will not preserve the column names, if any were present.

Value

A CSR matrix (class 'dgRMatrix', 'lgRMatrix', or 'ngRMatrix' depending on the inputs) with the inputs concatenated by rows.

See Also

rbind2-method

Examples

library(Matrix)
library(MatrixExtra)
options("MatrixExtra.quick_show" = FALSE)
v <- as(1:10, "sparseVector")
rbind_csr(v, v, v)

X <- matrix(1:20, nrow=2)
rbind_csr(X, v)

MatrixExtra documentation built on May 29, 2024, 2:53 a.m.