| [<-.HDF5Matrix | R Documentation |
Subsetting assignment for HDF5Matrix objects
## S3 replacement method for class 'HDF5Matrix'
x[i, j, ...] <- value
x |
An |
i |
Row indices (numeric, logical, or missing) |
j |
Column indices (numeric, logical, or missing) |
... |
Ignored |
value |
Values to assign (scalar, vector, or matrix) |
Writes data to the HDF5 dataset backing the HDF5Matrix object.
Supports:
Scalar assignment: X[i, j] <- 5
Vector assignment: X[i, ] <- c(1, 2, 3)
Matrix assignment: X[1:3, 1:3] <- matrix(...)
Full replacement: X[] <- matrix(...)
The value is automatically recycled or reshaped to match the target dimensions. Changes are written immediately to disk.
The modified HDF5Matrix object (invisibly)
tmp <- tempfile(fileext = ".h5")
# Create a matrix
X <- hdf5_create_matrix(tmp, "data/X", data = matrix(rnorm(100), 10, 10))
X <- hdf5_matrix(tmp, "data/X")
# Assign scalar
X[1, 1] <- 42
# Assign row
X[2, ] <- 1:10
# Assign block
X[1:3, 1:3] <- matrix(0, 3, 3)
hdf5_close_all()
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.