Question: Getting loadings of components from pcaMethods
0
gravatar for johnnytam100
14 days ago by
johnnytam10080
johnnytam10080 wrote:

I want to get the loadings of components from pcaMethods.

To illustrate the problem, I have a matrix x

    a   b   c
1   ... ... ...
2   ... ... ...
3   ... ... ...

By loadings(pca(x, method="nipals", nPcs=2)), I get

    PC1 PC2
a   ... ...
b   ... ...
c   ... ...

However, I want to get

    PC1 PC2
1   ... ...
2   ... ...
3   ... ...

Anyone knows how to do that?

Thanks a lot!

pca pcamethods • 68 views
ADD COMMENTlink modified 14 days ago by Philipp Bayer5.7k • written 14 days ago by johnnytam10080
0
gravatar for Philipp Bayer
14 days ago by
Philipp Bayer5.7k
Australia/Perth/UWA
Philipp Bayer5.7k wrote:

Wouldn't you just need to transpose your input table while keeping names intact?

tx = setNames(data.frame(t(x[,-1])), x[,1])
loadings(pca(tx, method="nipals", nPcs=2))
ADD COMMENTlink written 14 days ago by Philipp Bayer5.7k

Good idea! I had a similar thought but does it work for a PCA analysis that we just swap the columns and rows?

ADD REPLYlink modified 14 days ago • written 14 days ago by johnnytam10080
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1554 users visited in the last hour