Skip to content

PCA prcomp problem

2 messages · Deirdre Toher, Brian Ripley

#
I've just starting using the prcomp function, and I want to be able to extract
individual principal components (e.g. PC1, PC2) in vector format.  I haven't
been able to find any documentation that explains how to do this (or even if it
is possible).  Any help on the subject would be greatly appreciated.

Many thanks
Deirdre Toher
Teagasc National Food Centre
#
On Tue, 9 Nov 2004, Deirdre Toher wrote:

            
Depends of course what you mean: do you want the coefficients or the data 
predicted onto principal components?

The coefficients are component `rotation' of the result (see the help 
page).

Projections onto the PCs is component `x' of the result (see the help 
page).  E.g.

fit <- prcomp(USArrests, scale = TRUE, ret.x = TRUE)
PC1 <- fit$x[, 1]
PC2 <- fit$x[, 2]

OR predict(fit)  gives the projections of old (or new, with newdata) 
data onto the PCs.