[R] Problem with PCA

Gavin Simpson gavin.simpson at ucl.ac.uk
Thu Mar 6 10:45:06 CET 2008


On Wed, 2008-03-05 at 19:43 -0800, phuong thao wrote:
> Dear Ms/Mr,
> In a package, I want to use PCA function. The structure I used follow this
> page: http://www.statmethods.net/advstats/factor.html.
>        fit<-principle(mydata, nfactors=9, rotation=TRUE)
>    or:
>        result<-PCA(mydata)
> 
> But I don't known why R language in my computer noticed: "not found
> principle", "not found PCA".

You have several problems:

It is 'principal' not 'principle' components analysis; the instructions
on that page clearly say:

fit <- principal(mydata, nfactors=5, rotation=TRUE)
       ^^^^^^^^^

And finally, you are not following all the steps on that page. You
*have* to load a package to use functions contained within in it.

principal() is in the psych package, so load it by executing:

library(psych)

PCA() is in the FactoMineR package, so load it by executing:

library(FactoMineR)

On the site you mention, all the R code chunks are higlighted by being
in monospace font with a thick green border to the left of the block.
Make sure you enter all the lines in those code chunks exactly as types
otherwise you'll get errors like the ones reported here.

HTH

G

> I download and installed R-2.6.2-win32.exe.
> Thanks alot for answering me.
> Hue University, VietNam.
> 
> 	[[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.
-- 
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
 Dr. Gavin Simpson             [t] +44 (0)20 7679 0522
 ECRC, UCL Geography,          [f] +44 (0)20 7679 0565
 Pearson Building,             [e] gavin.simpsonATNOSPAMucl.ac.uk
 Gower Street, London          [w] http://www.ucl.ac.uk/~ucfagls/
 UK. WC1E 6BT.                 [w] http://www.freshwaters.org.uk
%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%



More information about the R-help mailing list