methods-princomp: Functionality for principal components analysis ('princomp')...

methods-princompR Documentation

Functionality for principal components analysis ('princomp') objects

Description

These methods extract data from, and attribute new data to, objects of class "princomp" as returned by stats::princomp().

Usage

## S3 method for class 'princomp'
as_tbl_ord(x)

## S3 method for class 'princomp'
recover_rows(x)

## S3 method for class 'princomp'
recover_cols(x)

## S3 method for class 'princomp'
recover_inertia(x)

## S3 method for class 'princomp'
recover_coord(x)

## S3 method for class 'princomp'
recover_conference(x)

## S3 method for class 'princomp'
recover_supp_rows(x)

## S3 method for class 'princomp'
recover_aug_rows(x)

## S3 method for class 'princomp'
recover_aug_cols(x)

## S3 method for class 'princomp'
recover_aug_coord(x)

Arguments

x

An ordination object.

Details

Principal components analysis (PCA), as performed by stats::princomp(), relies on an eigenvalue decomposition (EVD) of the covariance matrix X^TX of a data set X. stats::princomp() returns the EVD factor V as the loadings ⁠$loadings⁠. The scores ⁠$scores⁠ are obtained as XV and are accessible as supplementary elements.

Value

The recovery generics ⁠recover_*()⁠ return core model components, distribution of inertia, supplementary elements, and intrinsic metadata; but they require methods for each model class to tell them what these components are.

The generic as_tbl_ord() returns its input wrapped in the 'tbl_ord' class. Its methods determine what model classes it is allowed to wrap. It then provides 'tbl_ord' methods with access to the recoverers and hence to the model components.

Author(s)

Emily Paul, John Gracey

See Also

Other methods for eigen-decomposition-based techniques: methods-cmds, methods-eigen, methods-factanal

Other models from the stats package: methods-cancor, methods-cmds, methods-factanal, methods-kmeans, methods-lm, methods-prcomp

Examples

# data frame of Anderson iris species measurements
class(iris)
head(iris)

# compute unscaled row-principal components of scaled measurements
iris[, -5] %>%
  princomp() %>%
  as_tbl_ord() %>%
  print() -> iris_pca

# recover observation principal coordinates and measurement standard coordinates
head(get_rows(iris_pca))
get_cols(iris_pca)

# augment measurement coordinates with names and scaling parameters
(iris_pca <- augment_ord(iris_pca))

corybrunson/ordr documentation built on Feb. 24, 2025, 6:34 a.m.