Deletes an object (dataset or group) or an attribute from an HDF5 file. If the object or attribute does not exist, a warning is issued and the function returns successfully (no error is raised).
Arguments
- file
The path to the HDF5 file.
- name
The full path of the object to delete (e.g.,
"/data/dset"or"/groups/g1").- attr
The name of the attribute to delete.
If
NULL(the default), the object specified bynameis deleted.If a string is provided, the attribute named
attris removed from the objectname.
- warn
Emit a warning if the name/attr does not exist. Default:
TRUE
Examples
file <- tempfile(fileext = ".h5")
h5_create_file(file)
# Create some data and attributes
h5_write(matrix(1:10, 2, 5), file, "matrix")
h5_write("A note", file, "matrix", attr = "note")
# Review the file structure
h5_str(file)
#> /
#> └── matrix <uint8 × 2 × 5>
#> └── @note <utf8[6] × 1>
# Delete the attribute
h5_delete(file, "matrix", attr = "note")
# Review the file structure
h5_str(file)
#> /
#> └── matrix <uint8 × 2 × 5>
# Delete the dataset
h5_delete(file, "matrix")
# Review the file structure
h5_str(file)
#> /
# Cleaning up
unlink(file)
