juba / explor

Interfaces for Multivariate Analysis in R
https://juba.github.io/explor/
193 stars 13 forks source link

exporting results for PCA #28

Closed chisin closed 4 years ago

chisin commented 4 years ago

Hello, I have been using explor() for visualizing the results of dudi.PCA. I would like to export the info of the variables contributing to the different axes (in particular of the ones contributing most, which I suppose should be the ones with the highest "contrib" values). I tried running the "non-shiny" commands (e.g. res.var <- get_pca_var(res.pca) res.var$coord # Coordinates res.var$contrib # Contributions to the PCs res.var$cos2 # Quality of representation ), however the numbers do not correspond (e.g. the res.var$contrib command gives "0.00762", while explor shows "0.01". Is it because explor is rounding values? Thank you, C.

juba commented 4 years ago

You use the dudi.pca function from the ade4 package ? Where does the get_pca_var function comes from ?

juba commented 4 years ago

If I'm not mistaken, and if you're using dudi.pca, contributions values should be computed with :

inertia.dudi(res.pca, col.inertia = TRUE)$col.abs

And yes, values are rounded to two decimals in explor tables, that should explain the differences...

chisin commented 4 years ago

Yes, I use the dudi.pca function from ade4, combined with factoextra package (following instructions found here: http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/119-pca-in-r-using-ade4-quick-scripts/ ). Thank you for the prompt answer!