Learn R Programming

h5lite (version 2.0.0.2)

h5_names: Get Names of an HDF5 Object

Description

Returns the names of the object.

  • For Groups, it returns the names of the objects contained in the group (similar to ls()).

  • For Compound Datasets (data.frames), it returns the column names.

  • For other Datasets, it looks for a dimension scale and returns it if found.

Usage

h5_names(file, name = "/", attr = NULL)

Value

A character vector of names, or NULL if the object has no names.

Arguments

file

The path to the HDF5 file.

name

The full path of the object.

attr

The name of an attribute. If provided, returns the names associated with the attribute (e.g., field names if the attribute is a compound type). (Default: NULL)

Examples

Run this code
file <- tempfile(fileext = ".h5")

h5_write(data.frame(x=1, y=2), file, "df")
h5_names(file, "df") # "x" "y"

x <- 1:5
names(x) <- letters[1:5]
h5_write(x, file, "x")
h5_names(file, "x") # "a" "b" "c" "d" "e"

h5_write(mtcars[,c("mpg", "hp")], file, "dset")
h5_names(file, "dset") # "mpg" "hp"

unlink(file)

Run the code above in your browser using DataLab