Reputation: 9865
Datatypes in R have always confused me, and I'm sorry if this is an elementary question. I know that the $loadings
attribute in R is supposed to be a matrix. even the documentation says that if you type ?loadings
: it says it is the matrix of variable loadings
.
arrests_pca <- princomp(USArrests, cor=TRUE)
typeof(arrests_pca$loadings)
....returns
[1] "double"
...and so I tried to find the class:
> class(arrests_pca$loadings)
[1] "loadings"
Upvotes: 1
Views: 1468
Reputation: 44788
Use str(arrests_pca$loadings)
. It returns
loadings [1:4, 1:4] -0.536 -0.583 -0.278 -0.543 0.418 ...
- attr(*, "dimnames")=List of 2
..$ : chr [1:4] "Murder" "Assault" "UrbanPop" "Rape"
..$ : chr [1:4] "Comp.1" "Comp.2" "Comp.3" "Comp.4"
You can see on the first line that it's a 4x4 matrix.
Upvotes: 2