[R] Condensed PCA Results

From: Wayne Aldo Gavioli <wgavioli_at_fas.harvard.edu>
Date: Wed, 27 Jun 2007 15:25:41 -0400


Hello all,

I'm currently using R to do PCA Analysis, and was wondering if anyone knew the specific R Code that could limit the output of the PCA Analysis so that you only get the Principal Component features as your output and none of the extraneous words or numbers that you don't want.

If that was unclear, let me use linear regression as an example:

"lm(y~x)" is the normal command for linear regression, but it produces other
text and string aside from the regression coefficients.

"lm(y~x)$coefficients" gives you just the regression coefficients when you carry
out the command.

When I carry out PCA on R, typically I get:

Standard deviations:
[1] 83.732400 14.212402 6.489426 2.4827900

Rotation:

                PC1         PC2         PC3         PC4
Murder   0.04170432 -0.04482166  0.07989066 -0.99492173
Assault  0.99522128 -0.05876003 -0.06756974  0.03893830
UrbanPop 0.04633575  0.97685748 -0.20054629 -0.05816914
Rape     0.07515550  0.20071807  0.97408059  0.07232502


I want to get only:

                PC1         PC2         PC3         PC4
Murder   0.04170432 -0.04482166  0.07989066 -0.99492173
Assault  0.99522128 -0.05876003 -0.06756974  0.03893830
UrbanPop 0.04633575  0.97685748 -0.20054629 -0.05816914
Rape     0.07515550  0.20071807  0.97408059  0.07232502


I want to be able to do this because I am actually carrying out PCA in RExcel. I am able to do the PCA analysis using the "prcomp(data)" and "GetArray" commands, but doing that puts all of the aforementinoed output in a single row of cells instead of assigning each word and number its own individual cell.

I figured this dealt more with R code than Excel, so I decided to post it here.

Can anyone help me out? Is there a command that can carry out what I've mentioned?

Wayne



R-help_at_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 and provide commented, minimal, self-contained, reproducible code. Received on Wed 27 Jun 2007 - 19:39:02 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 27 Jun 2007 - 20:34:11 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.