Learn R Programming

ChemoSpec (version 4.4.97)

q2rPCA: Conversion Between PCA Classes

Description

Utility to convert objects of S3 class prcomp (Q-mode PCA) to objects of S3 class princomp (R-mode PCA) or vice-versa. An internal function, not generally called by the user.

Usage

q2rPCA(x)

Arguments

x

An object of either class prcomp or class princomp. It will be converted to a form that can be used by functions expecting either class.

Value

A list of class conPCA. Note that the order of the elements will vary depending upon the direction of conversion.

loadings

The loadings from princomp, or a copy of the rotations from prcomp.

scores

The scores from princomp, or a copy of the x values from prcomp.

call

The call. Objects of class prcomp do not store the original call, so a place holder is used. Otherwise the unchanged call from princomp.

n.obs

The number of observations from princomp, or computed from the 1st dimension of x in prcomp.

class

conPCA is pre-pended to the existing class.

sdev

Unchanged from original.

center

Unchanged from original.

scale

Unchanged from original.

Details

In the conversion, the necessary list elements are added; the old elements are not deleted (and user added list elements are not affected). To indicate this, the class attribute is updated to include class conPCA. The new object can then be used by functions expecting either class prcomp or princomp. For details of the structure of prcomp or princomp, see their respective help pages.

References

https://github.com/bryanhanson/ChemoSpec

See Also

prcomp, princomp