[R] How to set up number of prin comp.
Bjørn-Helge Mevik
bhx2 at mevik.net
Fri Feb 25 10:38:08 CET 2005
> I am trying to use PrinComp to do principle component analysis. I
> would like to know how to set the number of principle components.
I assume you mean the function princomp (case _does_ matter in R) in
package stats (which is loaded by default). This function has no way
of specifying how many components to calculate; it always gives you
all components. You have to select the components you want
afterwards. See help(princomp) for details. E.g.
X <- some matrix
pc <- princomp(X)
pc$scores[,1:4] # The four first score vectors
pc$loadings[,1:4] # The four first loadings
(The loadings can also be extracted with loadings(pc)[,1:4] .)
--
Bjørn-Helge Mevik
More information about the R-help
mailing list