[R] Help about princomp

Jari Oksanen jari.oksanen at oulu.fi
Mon Apr 23 12:59:32 CEST 2007

annina <wossona <at> yahoo.co.uk> writes:

> Hello,
> I have a problem with the princomp method, it seems stupid but I don't know
> how to handle it.
> I have a dataset with some regular data and some outliers. I want to
> calculate a PCA on the regular data and get the scores for all data,
> including the outliers. Is this possible on R? 
> Thank you for helping!!!

Dear Annina,

Yes, this is possible in R.

Both  'prcomp' (that I recommend) and 'princompä have 'predict' method which can
have 'newdata' as an argument. The following assumes that 'keep' is a vector
which is TRUE for cases you keep, and FALSE for those ignored:

pc <- prcomp(x[keep,])
predict(pc, newdata=x)

cheers, Jari Oksanen

More information about the R-help mailing list