h5_valid | R Documentation |
Check whether a 'HDF5' file can be opened for read/write
h5_valid(file, mode = c("r", "w"), close_all = FALSE)
file |
path to file |
mode |
|
close_all |
whether to close all connections or just close current
connection; default is false. Set this to |
logical whether the file can be opened.
x <- array(1:27, c(3,3,3))
f <- tempfile()
# No data written to the file, hence invalid
h5_valid(f, 'r')
save_h5(x, f, 'dset')
h5_valid(f, 'w')
# Open the file and hold a connection
ptr <- hdf5r::H5File$new(filename = f, mode = 'w')
# Can read, but cannot write
h5_valid(f, 'r') # TRUE
h5_valid(f, 'w') # FALSE
# However, this can be reset via `close_all=TRUE`
h5_valid(f, 'r', close_all = TRUE)
h5_valid(f, 'w') # TRUE
# Now the connection is no longer valid
ptr
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.