Write (updated) values back into existing HDF5 datasets (robust)
Source:R/hdf5_read-write.R
h5_write_values.RdWrites scalars, vectors, matrices/arrays, and 2-column data frames/tibbles (treated as time series) into existing HDF5 datasets. If the dataset reports SCALAR incorrectly, the function can infer target dimensions from the supplied value and resize accordingly.
Arguments
- h5
An open
hdf5r::H5File(e.g.,mode = "r+").- values
Named
list: names are absolute dataset paths, values are R objects to write.- resize
Logical. If
TRUE, resize datasets viaset_extent()when shapes differ.- strict
Logical. If
TRUE, stop on first error; otherwise warn and skip.- prefer_rows
Logical(1) or
NA. For 2-column time series:NAkeeps dataset orientation (2xN if first dim == 2),TRUEforces 2xN,FALSEforces Nx2.- ts_cols
Character(2). Column names to pull from time-series data frames (default
c("time","value")).- scalar_strategy
One of
"error","first","collapse". Controls how non-length-1 values are handled for true SCALAR datasets.- collapse_sep
Character. Separator used when
scalar_strategy = "collapse".- verbose
Logical. If
TRUE, prints per-path dimension info.
Examples
if (FALSE) { # \dontrun{
vals <- h5_read_values(h5)
vals[["/Parameters/OutputPath"]] <- "C:/temp/out.h5"
h5_write_values(h5, vals, resize = TRUE, scalar_strategy = "first", verbose = TRUE)
} # }