hdf5_matrix: Open an HDF5 dataset as an HDF5Matrix object

View source: R/HDF5Matrix_constructor.R

hdf5_matrixR Documentation

Open an HDF5 dataset as an HDF5Matrix object

Description

Opens an existing dataset in an HDF5 file and returns an HDF5Matrix object that can be used with standard R syntax: dim(), [i,j], %*%, crossprod(), and tcrossprod().

Usage

hdf5_matrix(filename, path)

Arguments

filename

Path to an existing HDF5 file

path

Full path to the dataset within the file, in the form "group/dataset" or "group/subgroup/dataset"

Details

The HDF5 file remains open while the object exists, which improves performance for repeated operations. Call $close() to release the file lock explicitly, or use rm() and gc() for automatic cleanup. In an emergency, hdf5_close_all closes all open HDF5Matrix objects.

Value

An HDF5Matrix object

See Also

hdf5_close_all, [.HDF5Matrix, crossprod.HDF5Matrix, tcrossprod.HDF5Matrix

Examples


tmp <- tempfile(fileext = ".h5")

# Create dataset using BigDataStatMeth API
X <- hdf5_create_matrix(tmp, "data/expression",
                         data = matrix(rnorm(200), 20, 10))

dim(X)         # 20 x 10
X[1:5, 1:3]   # subset
crossprod(X)   # t(X) %*% X

close(X)
unlink(tmp)



BigDataStatMeth documentation built on May 15, 2026, 1:07 a.m.