Projector Composition
compose_projectors.Rd
Compose a sequence of projector
objects in forward order.
This function allows the composition of multiple projectors, applying them sequentially to the input data.
Value
A composed_projector
object that extends the function
class, allowing the composed projectors to be
applied to input data.
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