Re: [R] PCA (prcomp) details info.

From: Bjørn-Helge Mevik <>
Date: Sun 14 Jan 2007 - 11:59:20 GMT

Francesco Savorani wrote:

> I'm handling a matrix dataset composed by a number of variables much
> higher than the objects (900 vs 100) and performing a prcomp
> (centered and scaled) PCA on it. What I get is a Loadings (rotation)
> matrix limited by my lower number of objects and thus 900x100
> instead of 900x900. If I try to manually calculate the matrix scores
> multiplying the original variables (centered and scaled) for such a
> loadings matrix I cannot obtain the same values calculated by R and
> stored on the prcomp$x matrix (100x100).

This works for me:

M <- matrix(rnorm(900*100), ncol = 900)
pca <- prcomp(M, scale = TRUE)
S <- scale(M) %*% pca$rotation
all.equal(S, pca$x) ## => TRUE

Bjørn-Helge Mevik

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Sun Jan 14 22:59:20 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sun 14 Jan 2007 - 14:00:34 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.