apply_function: Apply a statistical or algebraic function to HDF5 datasets...

View source: R/S3_operations.R

apply_functionR Documentation

Apply a statistical or algebraic function to HDF5 datasets (generic)

Description

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.

Usage

apply_function(x, ...)

Arguments

x

An HDF5Matrix.

...

Additional arguments forwarded to the method.

Details

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".

Value

Named list with elements filename, out_group, func, datasets.

See Also

hdf5_apply for the standalone file-path version; crossprod.HDF5Matrix, qr.HDF5Matrix for single-dataset S3 equivalents of the most common operations.

Examples


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)



BigDataStatMeth documentation built on June 8, 2026, 5:07 p.m.