View source: R/knownOperations.R
knownOperations | R Documentation |
Get or set loading functions for operations or arrays that were saved into the HDF5 file. This enables third-party packages to modify the chihaya framework for their own purposes.
knownOperations(operations)
knownArrays(arrays)
operations |
Named list of loading functions for operations.
Each function should accept the same arguments as |
arrays |
Named list of loading functions for arrays.
Each function should accept the same arguments as |
This function can be used to modify the loading procedure for existing operations/arrays or to add new loaders for new arrays.
Custom arrays should use a "custom "
prefix in the name to ensure that they do not clash with future additions to the chihaya specification.
If an instance of a custom array contains an r_package scalar string dataset inside its HDF5 group, the string is assumed to hold the name of the package that implements its loading handler;
if this package is installed, it will be automatically loaded and used by loadDelayed
.
Custom operations can be added, but they are not currently supported via validate
, so it is assumed that such operations will be created outside of saveDelayed
.
If operations
is missing, customLoadOperations
will return a list of the current custom operations that have been registered with chihaya.
If operations
is provided, it is used to define the set of custom operations, and the previous set of operations is returned.
The same approach is used for arrays
in customLoadArrays
.
Aaron Lun
library(HDF5Array)
X <- rsparsematrix(100, 20, 0.1)
Y <- DelayedArray(X)
Z <- log2(Y + 1)
temp <- tempfile(fileext=".h5")
saveDelayed(Z, temp)
# Overriding an existing operation:
ops <- knownOperations()
old_unary <- ops[["unary math"]]
ops[["unary math"]] <- function(file, path) {
cat("WHEE!\n")
old_unary(file, path)
}
old <- knownOperations(ops)
# Prints our little message:
loadDelayed(temp)
# Setting it back.
knownOperations(old)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.