Let x
be a sample dataframe.
set.seed(0)
x <- replicate(4, rnorm(10))
A PCA using the principal
function from
Here's a partial answer. I looked through the code behind the principal
function, and can see clearly where the reordering happens:
if (nfactors > 1) {
ev.rotated <- diag(t(loadings) %*% loadings)
ev.order <- order(ev.rotated, decreasing = TRUE)
loadings <- loadings[, ev.order]
}
So the code above is the reason the order changes, but it's less clear what purpose that serves. I don't have enough experience in rotations to be able to discern the package author's intent.