Given a PCA object created with prcomp, this function computes the percent of variance explained by each of the principal components.

getPcaVars(pca, digits = 3)

Arguments

pca

An object created with prcomp.

digits

The number of significant digits to round to.

Value

A vector with the percent of variance explained for each of the principal components in decreasing order.

Author

Andrew E Jaffe

Examples


pca <- prcomp(USArrests)
getPcaVars(pca)
#> [1] 96.6000  2.7800  0.5800  0.0849