Skip to content

Performs a principal components analysis on the given data matrix and returns the results as a prcomp class object. This function is "borrowed" from stats::prcomp(), except with some extra returned components of the SVD that are not returned by the standard function as well as hard coding the projection to be returned and some simple data checks.

Usage

prcomp2(x, tol = NULL)

Arguments

x

a numeric or complex matrix (or data frame) which provides the data for the principal components analysis.

tol

a value indicating the magnitude below which components should be omitted. (Components are omitted if their standard deviations are less than or equal to tol times the standard deviation of the first component.) With the default null setting, no components are omitted (unless rank. is specified less than min(dim(x)).). Other settings for tol could be tol = 0 or tol = sqrt(.Machine$double.eps), which would omit essentially constant components.

Value

A prcomp class object.

Note

We've simply hijacked prcomp() and added elements to the return value.

See also

Author

Stu Field, Mike R. Mehan