View source: R/S3_operations.R
| apply_function | R Documentation |
Generic S3 function that applies a predefined algebraic or statistical
operation to one or more named datasets within the HDF5 group of
x, writing the results to out_group.
This function is not equivalent to base::apply().
It does not apply an arbitrary R function row- or column-wise to the matrix
data of x. Instead, it dispatches one of several built-in C++
operations (QR, cross-product, Cholesky, etc.) to a batch of datasets
stored in the HDF5 file, which need not be open as HDF5Matrix
objects.
apply_function(x, ...)
x |
An |
... |
Additional arguments forwarded to the method. |
Two access patterns are available:
apply_function(x, datasets = c("A","B"), func = "QR") —
use when you have an open HDF5Matrix; x provides the
file and group context.
hdf5_apply(filename, group, datasets, func) —
use when you only have the file path and group name.
Valid func values: "QR", "CrossProd",
"tCrossProd", "invChol", "blockmult",
"CrossProd_double", "tCrossProd_double", "solve",
"normalize", "sdmean", "descChol".
Named list with elements filename, out_group,
func, datasets.
hdf5_apply for the standalone file-path version;
crossprod.HDF5Matrix, qr.HDF5Matrix for
single-dataset S3 equivalents of the most common operations.
fn <- tempfile(fileext = ".h5")
# Create two datasets in the same group
hdf5_create_matrix(fn, "data/A", data = matrix(rnorm(50), 5, 10))
hdf5_create_matrix(fn, "data/B", data = matrix(rnorm(50), 5, 10))
# Apply CrossProd to all datasets in the group
X <- hdf5_matrix(fn, "data/A")
res <- apply_function(X, func = "CrossProd", out_group = "RESULTS")
hdf5_close_all()
unlink(fn)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.