h5Overwrite {hdf5r.Extra} | R Documentation |
Overwrite an existing HDF5 link
h5Overwrite(file, name, overwrite)
file |
An existing HDF5 file |
name |
Name of HDF5 link to be overwritten. |
overwrite |
Whether or not to overwrite |
When file
doesn't exist, will create it.
When the old link name
doesn't exist, will simply return
file
.
When name
exists and overwrite
is TRUE
, will copy
the rest of HDF5 links to an updated file
with h5Backup
.
If name
is "/", will create a new file
and overwrite the old one.
When name
exists and overwrite
is FALSE
, will
raise an error.
Path to file
which is ready to be written.
file <- system.file("extdata", "pbmc_small.h5ad", package = "hdf5r.Extra")
tmp.file <- tempfile(fileext = ".h5")
file.copy(file, tmp.file)
obs <- h5Read(tmp.file, "obs")
h5Overwrite(tmp.file, "layers", TRUE)
stopifnot(!h5Exists(tmp.file, "layers"))
# You can still read other links.
obs2 <- h5Read(tmp.file, "obs")
stopifnot(identical(obs, obs2))