Re: [R] questions about principle component analysis (princomp)

From: Yunfeng Hu <yunfeng_at_scripps.edu>
Date: Fri 23 Jul 2004 - 03:42:48 EST

Thank you, Thomas. It is very helpful. I will dig more into the man page but for now I get what I want.

Yunfeng
On Jul 21, 2004, at 11:29 PM, Thomas Petzoldt wrote:

> Yunfeng Hu wrote:
>> Hi, I am a new R user and am currently using princomp to conduct a
>> PCA. I have read the help(princomp) and still do not quite understand
>> everything in the help. Basically I want to get the covariance
>> matrix, and eigenvector/eigenvalues (loadings()?) so that I can find
>> the principle components. Thanks!
>
> Hello,
>
> you may start with the examples at the bottom of the help page to get
> more understanding. Here is a modified version of that example:
>
> data(USArrests)
> pc<- princomp(USArrests)
>
> summary(pc)
> loadings(pc)
>
> plot(pc)
> biplot(pc)
>
> # some other useful methods mentioned on the help page:
>
> cov(USArrests) # covariance matrix
> eigen(cov(USArrests)) # eigenvalues/vector
>
> # and a way to show, what things are stored in pc
>
> str(pc)
>
> # so they can be extracted as shown on the help page.
>
> # Please note, that the scaled version (correlation matrix)
> # would be more appropriate there, e.g.
>
> pc<- princomp(USArrests, cor=TRUE)
> summary(pc)
> cor(USArrests)
> eigen(cor(USArrests))
>
>
> Hope it helps
>
> Thomas P.
>
>

###################################

Research Associate, Ph.D
Department of Molecular Biology, MB-5
The Scripps Research Institute
10550 North Torrey Pines Road
La Jolla, CA 92037
Tel. (858) 784-2204
Fax. (858) 784-2860
Emal: yunfeng@scripps.edu
Web: http://www.scripps.edu/~yunfeng
###################################

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Fri Jul 23 03:46:44 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:11 EST