Reads data from an HDF5 file, including attributes, into a nested list that preserves the hierarchical structure of the HDF5 data. The routine can read 64-bit integers and represent them as 64-bit integers in R via the bit64
package. It can also read 32-bit floating points values, not part of native R. These are automatically converted into 64-bit doubles.
readhdf5(file, subtree = "*", group.attr.as.data = FALSE, empty = FALSE)
Nested list representing the contents of the HDF5 file. Groups are nested sublists, datasets are represented by their data. Attributes of groups and datasets are attached as attributes to the corresponding sublists and data elements.
Character string specifying the file name of the input HDF5 file.
A structure specifying the HDF5 groups and datasets to be read. Use an asterisk "*"
(default) to read the entire file. To read only part of the file, provide a named list reflecting the hierarchy of groups, subgroups, and datasets. For (sub)groups, use nested lists containing the items to read, or use '*'
to load everything in the group. An empty list list()
reads only the attributes of a group. For datasets, use NULL
to read only attributes, or any other content to read the full data.
Logical flag. If TRUE
, group attributes are converted to datasets, which is useful for formats where parameters are stored as attributes (e.g., Gadget simulation outputs).
Logical flag. If TRUE
, only names of groups and datasets are returned, with all data equal to NA. This is a fast way of reading the hierarchical structure.
This function, based on the hdf5r
package, recursively parses and reads HDF5 files into nested lists that preserve the original hierarchy. Attributes in groups and datasets are included in the output.
writehdf5
for examples.