views:

136

answers:

1

I noticed something in R , say pc is the result of applying PCA to a data matrix and pc$x is my sample principal component matrix .

when try plot(pc$x) , it will only plot the first principal component (pc1) against the second (pc2) , but I actually have more than 2 principal components. how do I show all of them ?

A: 

All combinations in a single plot:

pairs(pc$x)

To select a specific combination just use:

plot(pc$x[, c(1,3)])  # e.g. pc1 and pc3
rcs
Is there a way I can combine plot with the rep function to plot for all principal components at once ?
phpdash
No, what's wrong with pairs()? You probably want something like `matplot(pc$x[,1], pc$x[,-1], pch=19)`.
rcs
pairs(pc$x) works well, but the problem is just that I have to many prinicpal components and the plots look very small , if I plot them all at once on 1 page .
phpdash
how aboutfor (i in 2:ncol(x)) { for (j in i:(i-1)) { plot(pc$x[,c(j,i)]) }}?
Ben Bolker