DataBackend for Matrix. Data is stored as (sparse) matrix.

Format

R6::R6Class object inheriting from DataBackend.

Construction

DataBackendMatrix$new(data, primary_key = NULL)
as_data_backend(data, primary_key = NULL, ...)
  • data :: Matrix::Matrix().

  • primary_key :: character(1)
    Not supported by this backend. Rows are addresses by their rownames(). If the matrix does not have row names, integer row indices are used.

Fields

See DataBackend.

Methods

See DataBackend.

See also

Examples

#> Loading required namespace: Matrix
data = Matrix::Matrix(sample(0:1, 20, replace = TRUE), ncol = 2) colnames(data) = c("x1", "x2") rownames(data) = paste0("row_", 1:10) b = as_data_backend(data) b$head()
#> x1 x2 ..row_id #> 1: 1 1 row_1 #> 2: 0 0 row_2 #> 3: 0 0 row_3 #> 4: 1 1 row_4 #> 5: 1 0 row_5 #> 6: 0 1 row_6
b$data(b$rownames[1:3], b$colnames, data_format = "Matrix")
#> 3 x 2 Matrix of class "dgeMatrix" #> x1 x2 #> row_1 1 1 #> row_2 0 0 #> row_3 0 0