[R] Factor Loadings in Vegan's PCA

Nikos Alexandris nikos.alexandris at felis.uni-freiburg.de
Thu Jul 1 03:21:31 CEST 2010


On Wednesday 30 of June 2010 23:02:09 afsouza at unisinos.br wrote:
> Hi all,
> 
>    I am using the vegan package to run a prcincipal components analysis
> on forest structural variables (tree  density, basal area, average
> height, regeneration density) in R.
> 
>    However, I could not find out how to extract factor loadings
> (correlations of each variable with each pca axis), as is straightforwar
> in princomp.
> 
>    Do anyone know how to do that?
> 
>    Moreover, do anyone knows a function r package that produces
> rotated-pca and biplots? Most packages I found did only one of these
> tasks (princomp, psych, vegan).
> 
>    Thanks a lot,
>    Alexandre

Hi Alexandre.

I haven't used the vegan package. But using princomp() and/or prcomp() is 
really easy. Easy is also the extraction of the loadings. Just check the 
structure of the result of princomp() to find the "loadings" or the result of 
prcomp() to find the "rotation" ( which is the same as the loadings in 
princomp() ).

For plotting you might want to have a look at the plotpc R package. It's 
something I really like (and have customised it a lot to suit my needs of 
plotting bivariate rotated axes (=the principal components) of a given data 
set using the prcomp R function and even more). Don't know though if this is 
what you are looking for.

( ...my custom version however is not ready for a generic use. It would take 
to somebody to spend more time on it to remove hardcoded stuff and figure out 
smart automatic ways to handle co-plotting scaled and non-scaled axes (as a 
result of scaled=standardised and non-scaled=unstandardised PCA) on the same 
plot.)

Also interesting is the smoothScatter functions that "produces a smoothed 
color density representation of the scatterplot, obtained through a kernel 
density estimate." It used "densCols" to "produce a vector containing colors 
which encode the local densities at each point in a scatterplot." Very 
interesting if the data-matrix to be transformed is large.

Nikos



More information about the R-help mailing list