remove_components: Remove principal components from data

View source: R/dim-reduction.R

remove_componentsR Documentation

Remove principal components from data

Description

Reconstruct data after removing principal components. This function will reconstruct a truncated version of the original data matrix after removing the specified principal components. The source code for this function was stolen from stack exchange

Usage

remove_components(x, components = 1, ...)

Arguments

x

data.frame or matrix of original data.

components

numeric vector of components to remove from original data. Default (1)

...

Additional arguments passed to prcomp()

Value

data.frame of values in the original units after removing components

Examples

# Remove first two components from dataset
trunc <- remove_components(USArrests, components = 1:2, scale. = TRUE, center = TRUE)

# original data
head(USArrests)

# reconstructed data
head(trunc)

jcalendo/coriell documentation built on March 5, 2025, 5:42 a.m.