[R] graphing of Princomp object

Tobias Verbeke tobias.verbeke at telenet.be
Sat Jan 15 16:30:15 CET 2005


On Sat, 15 Jan 2005 15:53:18 +0100
List account <lists at norvelle.org> wrote:

> Thanks, Tobias for the response.
> 
> I tried the suggestion you gave, and apparently (at least according to 
> the biplot manpage, only the first two members of the col vector are 
> used, the first to plot the first set of values, i.e. the scores, and 
> the second color is used for the loadings (I think I have that right).  
> At any rate, if I add the clause 'col = c(rep("red", 100), rep("blue", 
> 17), rep("green", 62))' I just get a bunch of red points! :(

You're right. I'm sorry I did not read ?biplot, but only checked it had
a col argument (Semel in anno licet insanire..). 
Anyway, with PCA it is not a good idea to plot both variables and
cases on one single plot, because the temptation is too great to interpret
proximities between variables and cases. You'd better plot two different
graphs, one for the cases and one for the `circle of correlations'.

For plotting the cases, you could make up your own plot using
something similar to this:

library(MASS) # for eqscplot
F1 <- yourpca$score[,1]
F2 <- yourpca$score[,2]
eqscplot(F1, F2, pch = 20)
text(F1, F2, labels = names(F1), 
     col = c(rep("red", 100), 
             rep("blue", 17), 
             rep("green", 62)),
     pos = 3)


Tobias

> Si vales, valeo...
> 
> -Erik




More information about the R-help mailing list