Search code examples
rpca

Principal component analysis in R with prcomp: Reduced number of dimensions after rotation


I have a dataset with 900 examples and 3600 variables (See example #1). I did a PCA using prcomp (See example #3). Then I rotate it by #3.

data <- as.data.frame(replicate(3600, rnorm(900))); #1
pca <- prcomp(data, center = TRUE, scale. = TRUE) ;  #2
rot <- as.matrix(data) %*% pca$rotation; #3

Now the dimension of rot is 900x900, but it should be 900x3600. Why does this happen?

Best, Thosten


Solution

  • I simply had to add more examples than variables and everything works fine. princomp() is actually forces to user to do this but prcomp() not.

    Best, Thorsten