SFBM-class | R Documentation |
A reference class for storing and accessing sparse matrix-like data stored in files on disk.
Convert a 'dgCMatrix' or 'dsCMatrix' to an SFBM.
as_SFBM(spmat, backingfile = tempfile(), compact = FALSE)
spmat |
A 'dgCMatrix' (non-symmetric sparse matrix of type 'double') or 'dsCMatrix' (symmetric sparse matrix of type 'double'). |
backingfile |
Path to file where to store data. Extension |
compact |
Whether to use a compact format? Default is |
An object of class SFBM has many fields:
$address
: address of the external pointer containing the underlying
C++ object to be used as a XPtr<SFBM>
in C++ code
$extptr
: (internal) use $address
instead
$nrow
: number of rows
$ncol
: number of columns
$nval
: number of non-zero values
$p
: vector of column positions
$backingfile
or $sbk
: File with extension 'sbk' that stores the
data of the SFBM
$rds
: 'rds' file (that may not exist) corresponding to the 'sbk' file
$is_saved
: whether this object is stored in $rds
?
And some methods:
$save()
: Save the SFBM object in $rds
. Returns the SFBM.
$add_columns()
: Add new columns from a 'dgCMatrix' or a 'dsCMatrix'.
The new SFBM.
spmat2 <- Matrix::Diagonal(4, 0:3) spmat2[4, 2] <- 5 spmat2[1, 4] <- 6 spmat2[3, 4] <- 7 spmat2 # Stores all (i, x) for x != 0 (X2 <- as_SFBM(spmat2)) matrix(readBin(X2$sbk, what = double(), n = 100), 2) # Stores only x, but all (even the zero ones) from first to last being not 0 (X3 <- as_SFBM(spmat2, compact = TRUE)) X3$first_i readBin(X3$sbk, what = double(), n = 100)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.