I am using the psych
package's fa
command for factor analysis, and so have an object of class fa
. I can query the loadings with fac$loadings
, but I want to only extract the table containing the loadings, so I can use xtable
(or similar) to convert it into LaTeX format.
Example code:
library(psych)
library(xtable)
data(bfi)
fac <- fa(r=cor(bfi, use="complete.obs"), nfactors=5, fm="ml", rotate="none")
fac$loadings
ld <- someMagicalFunction(fac$loadings)
xtable(ld)
Can anyone tell me what I can use for someMagicalFunction
?
When you look at fac$loading
, you see that it is a S3 object. Removing the class attribute gives you a matrix
which can then be passed to xtable
:
str(fac$loadings)
class(fac$loadings)
xtable(unclass(fac$loadings))