h5_class: Get R Class of an HDF5 Object or Attribute

h5_classR Documentation

Get R Class of an HDF5 Object or Attribute

Description

Inspects an HDF5 object (or an attribute attached to it) and returns the R class that h5_read() would produce.

Usage

h5_class(file, name, attr = NULL)

Arguments

file

The path to the HDF5 file.

name

The full path of the object (group or dataset) to check.

attr

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

Details

This function determines the resulting R class by inspecting the storage metadata.

  • Group \rightarrow "list"

  • Integer \rightarrow "numeric"

  • Floating Point \rightarrow "numeric"

  • String \rightarrow "character"

  • Complex \rightarrow "complex"

  • Enum \rightarrow "factor"

  • Opaque \rightarrow "raw"

  • Compound \rightarrow "data.frame"

  • Null \rightarrow "NULL"

Value

A character string representing the R class (e.g., "integer", "numeric", "complex", "character", "factor", "raw", "list", "NULL"). Returns NA_character_ for HDF5 types that h5lite cannot read.

See Also

h5_typeof(), h5_read()

Examples

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

h5_write(1:10, file, "my_ints", as = "int32")
h5_class(file, "my_ints") # "numeric"

h5_write(mtcars, file, "mtcars")
h5_class(file, "mtcars") # "data.frame"

h5_write(c("a", "b", "c"), file, "strings")
h5_class(file, "strings") # "character"

h5_write(c(1, 2, 3), file, "my_floats", as = "float64")
h5_class(file, "my_floats") # "numeric"

unlink(file)

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