list_datasets: List datasets in an HDF5 file or group

View source: R/S3_utils.R

list_datasetsR Documentation

List datasets in an HDF5 file or group

Description

Lists datasets within an HDF5 file. If no group is specified, the entire file is traversed recursively and full relative paths are returned (e.g. "INPUT/A", "RESULTS/SVD/d"). If a group is given, only the datasets in that group are listed unless recursive = TRUE.

Usage

list_datasets(x, group = NULL, prefix = NULL, recursive = FALSE)

Arguments

x

An HDF5Matrix object, or a character string (file path).

group

Character or NULL. Group path inside the HDF5 file. If NULL and x is a file path, the whole file is listed recursively. If NULL and x is an HDF5Matrix, the object's own group is used (non-recursive).

prefix

Optional character. Only return datasets whose name starts with this prefix.

recursive

Logical. If TRUE, recurse into subgroups and return full relative paths. Default FALSE.

Value

Character vector of dataset names or relative paths.

See Also

hdf5_matrix, hdf5_create_matrix

Examples


fn <- tempfile(fileext = ".h5")
hdf5_create_matrix(fn, "INPUT/A",    data = matrix(rnorm(100), 10, 10))
hdf5_create_matrix(fn, "INPUT/B",    data = matrix(rnorm(100), 10, 10))
hdf5_create_matrix(fn, "RESULTS/C",  data = matrix(rnorm(100), 10, 10))

# All datasets in the file (recursive from root)
list_datasets(fn)

# Only INPUT group
list_datasets(fn, group = "INPUT")

# From an HDF5Matrix object (uses object's own group)
X <- hdf5_matrix(fn, "INPUT/A")
list_datasets(X)

hdf5_close_all()
unlink(fn)



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