Description Usage Arguments Details Value Author(s) References See Also Examples
R function to create an HDF5 dataset and defining its dimensionality and compression behaviour.
1 2 3 4 5 6 |
file |
The filename (character) of the file in which the dataset will be located. For advanced programmers it is possible to provide an object of class |
dataset |
Name of the dataset to be created. The name can contain group names, e.g. 'group/dataset', but the function will fail, if the group does not yet exist. |
dims |
The dimensions of the array as they will appear in the file. Note, the dimensions will appear in inverted order when viewing the file with a C-programm (e.g. HDFView), because the fastest changing dimension in R is the first one, whereas the fastest changing dimension in C is the last one. |
maxdims |
The maximum extension of the array. Use |
storage.mode |
The storage mode of the data to be written. Can be obtained by |
H5type |
Advanced programmers can specify the datatype of the dataset within the file. See |
size |
For |
chunk |
The chunk size used to store the dataset. It is an integer vector of the same length as |
fillValue |
Standard value for filling the dataset. The storage.mode of value has to be convertable to the dataset type by HDF5. |
level |
The compression level used. An integer value between 0 (no compression) and 9 (highest and slowest compression). |
filter |
Character defining which compression filter should be applied to the chunks of the dataset. See the Details section for more information on the options that can be provided here. |
shuffle |
Logical defining whether the byte-shuffle algorithm should be applied to data prior to compression. |
native |
An object of class |
.
Creates a new dataset in an existing HDF5 file. The function will fail if the file doesn't exist or if there exists already another dataset with the same name within the specified file.
The filter
argument can take several options matching to compression
filters distributed in either with the HDF5 library in Rhdf5lib or via the
rhdf5filters package. The plugins available and the corresponding values
for selecting them are shown below:
"GZIP"
,
"ZLIB"
,
"DEFLATE"
"SZIP"
"BZIP2"
"BLOSC_BLOSCLZ"
"BLOSC_LZ4"
"BLOSC_LZ4HC"
"BLOSC_SNAPPY"
"BLOSC_ZLIB"
"BLOSC_ZSTD"
"NONE"
Returns TRUE is dataset was created successfully and FALSE otherwise.
Bernd Fischer, Mike L. Smith
https://portal.hdfgroup.org/display/HDF5
h5createFile
, h5createGroup
, h5read
, h5write
, rhdf5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | h5createFile("ex_createDataset.h5")
# create dataset with compression
h5createDataset("ex_createDataset.h5", "A", c(5,8), storage.mode = "integer", chunk=c(5,1), level=6)
# create dataset without compression
h5createDataset("ex_createDataset.h5", "B", c(5,8), storage.mode = "integer")
h5createDataset("ex_createDataset.h5", "C", c(5,8), storage.mode = "double")
# create a dataset of strings & define size based on longest string
ex_strings <- c('long', 'longer', 'longest')
h5createDataset("ex_createDataset.h5", "D",
storage.mode = "character", chunk = 3, level = 6,
dims = length(ex_strings), size = max(nchar(ex_strings)))
# write data to dataset
h5write(matrix(1:40,nr=5,nc=8), file="ex_createDataset.h5", name="A")
# write second column
h5write(matrix(1:5,nr=5,nc=1), file="ex_createDataset.h5", name="B", index=list(NULL,2))
# write character vector
h5write(ex_strings, file = "ex_createDataset.h5", name = "D")
h5dump("ex_createDataset.h5")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.