Search code examples
rpca

View PCA component matrix in R


I am using R for a PCA, using the function princomp (I'm also open to using prcomp). I'd like to view the component matrix, as found in SPSS, where each variable is correlated to each component.

Note this is different to the loadings which princomp can return for you.

Can I call it directly from my princomp output, or is there a hacky way I can generate it?


Solution

  • For princomp

    data(iris)
    pc <- princomp(iris[,1:3)
    pc$loadings
    

    you can looking at str(pc) so see all the elements of the object generated by princomp.

    For prcomp I think the equivalent is

    pc <- prcomp(iris[,1:3])
    pc$rotation