# How to project a vector onto matrix of rotation in PCA

I want to project a vector onto space transformed by PCA. I've calculated PCA in R language using prcomp.

Now I should be able to multiply my vector by matrix of rotation.

Should principal components in this matrix be arranged in rows or columns?

Vector that I want to project:

attr1 attr2 ...


Rotation matrix:

PC1 PC2 PC3 ...
... ... ...

-
What do you call 'Pca matrix' or matrix of eigenvalues? There is only a vector of eigenvalues, and eventually a matrix of rotation. –  chl Sep 12 '10 at 16:21
Sorry, my inaccuracy - By 'PCA matrix' I meant matrix of rotation –  pixel Sep 12 '10 at 16:25

Well, @Srikant already gave you the right answer since the rotation (or loadings) matrix contains eigenvectors arranged column-wise, so that you just have to multiply (using %*%) your vector or matrix of new data with e.g. prcomp(X)\$rotation. Be careful, however, with any extra centering or scaling parameters that were applied when computing PCA EVs.

In R, you may also find useful the predict() function, see ?predict.prcomp. BTW, you can check how projection of new data is implemented by simply entering:

getS3method("predict", "prcomp")

-