jpm miao
2012-Aug-23 03:34 UTC
[R] Accessing the (first or more) principal component with princomp or prcomp
Hi , To my knowledge, there're two functions that can do principal component analysis, princomp and prcomp. I don't really know the difference; the only thing I know is that when the sample size < number of variable, only prcomp will work. Could someone tell me the difference or where I can find easy-to-read reference? To access the first PC using princomp: Mpca<-princomp(M, cor=T) Mpca$scores[,1] How can I access the first PC using prcomp? Mpca<-prcomp(M) Is there an option for "cor=T"? In case where both functions work, will the results be the same? Thanks, Miao [[alternative HTML version deleted]]
Bert Gunter
2012-Aug-23 04:42 UTC
[R] Accessing the (first or more) principal component with princomp or prcomp
How about reading the Help files? -- Bert On Wed, Aug 22, 2012 at 8:34 PM, jpm miao <miaojpm at gmail.com> wrote:> Hi , > > To my knowledge, there're two functions that can do principal component > analysis, princomp and prcomp. > > I don't really know the difference; the only thing I know is that when > the sample size < number of variable, only prcomp will work. Could someone > tell me the difference or where I can find easy-to-read reference? > > To access the first PC using princomp: > Mpca<-princomp(M, cor=T) > Mpca$scores[,1] > > How can I access the first PC using prcomp? > Mpca<-prcomp(M) > > Is there an option for "cor=T"? > In case where both functions work, will the results be the same? > > Thanks, > > Miao > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org 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.-- Bert Gunter Genentech Nonclinical Biostatistics Internal Contact Info: Phone: 467-7374 Website: http://pharmadevelopment.roche.com/index/pdb/pdb-functional-groups/pdb-biostatistics/pdb-ncb-home.htm