My question is concerned with the principal() function in psych package.
set.seed(0)
x <- replicate(8, rnorm(10))
pca.x <- principal(x, nf=4, rotate="varimax")
I know if I want to see the loadings table, I can use loading.x <-loadings(pca.x)
, than I will have the following results.
> loading.x
Loadings:
RC1 RC3 RC4 RC2
[1,] -0.892 -0.205 0.123
[2,] 0.154 0.158 0.909
[3,] -0.660 0.255 -0.249 0.392
[4,] -0.352 0.412 0.614 -0.481
[5,] 0.950 -0.208 0.117
[6,] -0.302 0.111 0.860
[7,] 0.852 -0.195 -0.358
[8,] -0.109 0.903 0.265
RC1 RC3 RC4 RC2
SS loadings 2.323 1.934 1.373 1.342
Proportion Var 0.290 0.242 0.172 0.168
Cumulative Var 0.290 0.532 0.704 0.871
My first confusion is the loadings object. Technically, it is a matrix, but look at its dimension, it is 8 * 4, which means the lower part is not included.
Basically, what I want to achieve is to extract this part alone:
RC1 RC3 RC4 RC2
SS loadings 2.323 1.934 1.373 1.342
Proportion Var 0.290 0.242 0.172 0.168
Cumulative Var 0.290 0.532 0.704 0.871
Either put it in a data.frame or a matrix, rather than looking at it in the console. It seems that William Revelle's answer in the post Extracting output from principal function in psych package as a data frame. is able to extract this lower part alone, but the print
function still gives me the whole thing.
In fact, I'm also curious how the developers are able to construct a loading object (I can't figure it out by look at source code). Also, the part I need I can't find elsewhere in the 'pca.x' list, at least not a formatted table. I am using Rstudio Version 0.98.1102, R 3.1.2, on a mac, and psych 1.5.1.
Thank you in advance!