Skip to content
Prev 217393 / 398498 Next

PCA scores

On Fri, 2010-04-16 at 10:23 -0700, phoebe kong wrote:
You need to apply the centring and scaling done because you set 'cor =
TRUE' in your princomp call. Here's an example using the inbuilt 'swiss'
data set.

data(swiss)
pc <- princomp(swiss, cor = TRUE)
my.scr <- with(pc, scale(swiss, center = center, scale = scale) %*% 
                   loadings(pc))
all.equal(my.scr, pc$scores)

You can see all of this in the princomp code if you look closely:

getAnywhere(princomp.default)

HTH