View source: R/HDF5Matrix_create.R
| hdf5_create_matrix | R Documentation |
Creates a new HDF5 dataset (optionally writing data) and returns an
HDF5Matrix object pointing to it.
hdf5_create_matrix(
filename,
dataset,
nrow = NULL,
ncol = NULL,
data = NULL,
dtype = c("double", "integer", "logical"),
overwrite = FALSE,
compression = NULL
)
filename |
Character. Path to the HDF5 file (created if it does not exist). |
dataset |
Character. Full path inside the HDF5 file in
|
nrow |
Integer or NULL. Number of rows. Required when |
ncol |
Integer or NULL. Number of columns. Required when |
data |
Numeric matrix, integer matrix, or numeric vector, or NULL.
When non-NULL, the data are written to the new dataset. When NULL,
an empty (zero-filled) dataset of size |
dtype |
Character. Element type: |
overwrite |
Logical. If |
compression |
Integer (0-9) or NULL. gzip compression level.
|
Replaces the legacy bdCreate_hdf5_matrix() / bdCreate_hdf5_emptyDataset()
calls in the R6+S3 interface. The legacy functions remain available for
backward compatibility.
Row and column names stored in the dimnames attribute of data
are written to the HDF5 file automatically.
An HDF5Matrix object pointing to the created dataset.
hdf5matrix_options to set global compression default.
tmp <- tempfile(fileext = ".h5")
# Create from matrix data
mat <- matrix(rnorm(200), nrow = 20, ncol = 10)
X <- hdf5_create_matrix(tmp, "data/X", data = mat)
dim(X) # 20 x 10
# Create empty dataset
Y <- hdf5_create_matrix(tmp, "data/Y", nrow = 1000, ncol = 500)
dim(Y) # 1000 x 500
# No compression (useful for benchmarks or intermediate results)
Z <- hdf5_create_matrix(tmp, "data/Z", data = mat, compression = 0)
X$close(); Y$close(); Z$close()
unlink(tmp)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.