On Fri, 2005-02-25 at 20:29 +0800, [EMAIL PROTECTED] wrote: > Hi Bjrn-Helge, > > Thanks for your help. > > In my case, there are more variables in the matrix than the units, > so I have to use Prcomp with covariance to do PCA. The problem I am facing > is how to get fisrt 8 coefficients and scores and how to write the result > into text file. Thanks again. > > When I change princomp to prcomp below, I will NULL for pc$scores > & pc$loadings. > > X <- some matrix > pc <- prcomp(X) > pc$scores[,1:4] # The four first score vectors > pc$loadings[,1:4] # The four first loadings > Three most useful commands are help(), str() and names().
The first tells you how to use prcomp() and how it names its results. Try help(prcomp). The second peeks into the result so you see what is in there. Try (with your result) srt(pc). The third tells you what names are available in your result. The first (help) is the most useful of these commands, since it tells you what these names and items are. If you read it, you should say: pc$x[, 1:4] # The four first score vectors pc$rotation[, 1:4] # The four first loadings Also, loadings(pc) should work with prcomp. I think I'll write functions as.prcomp.princomp and as.princomp.prcomp someday. cheers, jari oksanen -- Jari Oksanen <[EMAIL PROTECTED]> ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html