View source: R/delarr-backends.R
| delarr_hdf5 | R Documentation |
Uses hdf5r to lazily read slices from disk on demand.
delarr_hdf5(path, dataset)
path |
Path to the HDF5 file. |
dataset |
Name of the dataset within the file. |
A delarr that streams data from the HDF5 dataset.
if (requireNamespace("hdf5r", quietly = TRUE)) {
# Create a temporary HDF5 file
tf <- tempfile(fileext = ".h5")
data <- matrix(1:20, nrow = 4, ncol = 5)
# Write test data
f <- hdf5r::H5File$new(tf, mode = "w")
f$create_dataset("X", robj = data)
f$close_all()
# Load as delayed array
darr <- delarr_hdf5(tf, "X")
darr
# Apply operations and collect
result <- darr |> d_map(~ .x * 2) |> collect()
result
# Clean up
unlink(tf)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.