Skip to contents

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(...)

Arguments

...

The sequence of projector objects to be composed.

Value

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

See also

Examples

# 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))
#> [1] TRUE