Reads an attribute associated with an HDF5 object (dataset or group).
Value
A numeric, character, complex, factor, or raw vector/array.
Returns NULL if the attribute has a null dataspace.
Details
Numeric attributes are read as
numeric(double).String attributes are read as
character.Complex attributes are read as
complex.enumattributes are read asfactor.1-byte
opaqueattributes are read asraw.
Examples
file <- tempfile(fileext = ".h5")
# Create a dataset to attach attributes to
h5_write(file, "dset", 1)
# Write attributes of different types
h5_write_attr(file, "dset", "a_string", "some metadata")
h5_write_attr(file, "dset", "a_vector", c(1.1, 2.2))
# Read them back
str_attr <- h5_read_attr(file, "dset", "a_string")
vec_attr <- h5_read_attr(file, "dset", "a_vector")
print(str_attr)
#> [1] "some metadata"
print(vec_attr)
#> [1] 1.1 2.2
unlink(file)
