Revision b6fe861fe48f12c1b45d1e68f8508ee6503821ac authored by Gilles Raiche on 24 April 2007, 00:00 UTC, committed by Gabor Csardi on 24 April 2007, 00:00 UTC
1 parent 4e9967d
Raw File
principalComponents.r
"principalComponents" <-
function(R) {
 nVar   <- dim(R)[2]
 acp             <- eigen(R)
 values          <- acp$values
 vectors         <- acp$vectors # Normed vecteurs to 1
 varExplained    <- round((values/nVar)*100,    2)
 cumVarExplained <- round(cumsum(varExplained), 2)
 loadings        <- vectors  %*% diag(values^0.5)  # F1 * diag(E)
 acp             <- list(values          = values,
                         varExplained    = varExplained,
                         cumVarExplained = cumVarExplained,
                         vectors         = vectors,
                         loadings        = loadings)
 return(acp)
 }

back to top