Learn R Programming

multivarious (version 0.2.0)

compose_projectors: Projector Composition

Description

Compose a sequence of projector objects in forward order. This function allows the composition of multiple projectors, applying them sequentially to the input data.

Usage

compose_projectors(...)

Value

A composed_projector object that extends the function class, allowing the composed projectors to be applied to input data.

Arguments

...

The sequence of projector objects to be composed.

See Also

projector, project

Examples

Run this code
# Create two PCA projectors and compose them
X <- matrix(rnorm(20*20), 20, 20)
pca1 <- pca(X, ncomp=10)
X2 <- scores(pca1)
pca2 <- pca(X2, ncomp=4)

# Compose the PCA projectors
cproj <- compose_projectors(pca1, pca2)

# Ensure the output of the composed projectors has the expected dimensions
stopifnot(ncol(cproj(X)) == 4)
# Check that the composed projectors work as expected
all.equal(project(cproj, X), cproj(X))

Run the code above in your browser using DataLab