h5_dim: Get Dimensions of an HDF5 Object or Attribute

h5_dimR Documentation

Get Dimensions of an HDF5 Object or Attribute

Description

Returns the dimensions of a dataset or an attribute as an integer vector. These dimensions match the R-style (column-major) interpretation.

Usage

h5_dim(file, name, attr = NULL)

Arguments

file

The path to the HDF5 file.

name

Name of the dataset or object.

attr

The name of an attribute to check. If NULL (default), the function returns the dimensions of the object itself.

Value

An numeric vector of dimensions, or numeric(0) for scalars.

Examples

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

h5_write(matrix(1:10, 2, 5), file, "matrix")
h5_dim(file, "matrix") # 2 5

h5_write(mtcars, file, "mtcars")
h5_dim(file, "mtcars") # 32 11

h5_write(I(TRUE), file, "my_bool")
h5_dim(file, "my_bool") # numeric(0)

h5_write(1:10, file, "my_ints")
h5_dim(file, "my_ints") # 10

unlink(file)

h5lite documentation built on May 19, 2026, 1:07 a.m.