read_hdf5: Read a matrix from an HDF5 file

View source: R/delarr-writer-hdf5.R

read_hdf5R Documentation

Read a matrix from an HDF5 file

Description

Simple convenience function to read a matrix from an HDF5 dataset. For lazy/streaming access, use delarr_hdf5() instead.

Usage

read_hdf5(path, dataset)

Arguments

path

Path to the HDF5 file.

dataset

Name of the dataset to read.

Value

The matrix stored in the dataset.

Examples

if (requireNamespace("hdf5r", quietly = TRUE)) {
  # Write and read back
  mat <- matrix(1:20, nrow = 4, ncol = 5)
  tf <- tempfile(fileext = ".h5")
  write_hdf5(mat, tf, "X")
  read_hdf5(tf, "X")

  # Clean up
  unlink(tf)
}

delarr documentation built on July 1, 2026, 1:06 a.m.