# Can I Use The Same Principal Components Of One Dataset To Graph Another Dataset In R?

I have two matrices of equal dimensions $$(m \times n)$$. If it helps, one matrix is the raw data, while the other is transformed.

I've plotted PC1 vs PC2 for both datasets individually, but then I realized I couldn't compare directly because the principal components likely change between the two matrices.

So is there a way, in R, that I can plot matrix2 using PC1 and PC2 from matrix1?

• As long as the dimensions are consistent, you can. This becomes a linear algebra question. If you make it an "R" question, then folks here will get truculent. – EngrStudent - Reinstate Monica Feb 10 '17 at 17:45

The prcomp function in R has a handy predict method:
set.seed(42)