if x is your matrix, then prcomp(x)$rotation gets you what you want Katharina
Wayne Aldo Gavioli schrieb: > 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 > > ______________________________________________ > [email protected] 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. > ______________________________________________ [email protected] 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.
