# R - How to the new data set (Y) from principal component analysis (PX =Y) [closed]

I have done all my principal component analysis and have my principal components (PC1 & PC2) and I know I have to multiply that by my original data set to get my new reduced data set, but I keep getting an error 'Error in Fish %*% FishPC : requires numeric/complex matrix/vector arguments'

My data set is called Fish and my Principal component matrix is FishPC My code is Fish %*% FishPC. I can provide more if needed.

My principal component matrix

My dataset

I have tried removing the species and that also did not work.

Y <- as.matrix(Fish[,2:7],nrow=nrow(Fish),ncol=6)%*%as.matrix(FishPC,nrow=6,ncol=2)

However, be aware of how the PCs were computed. PCA is often performed on data that has been centered and sometimes scaled. If that is the case for your PCs, then you should also center and/or scale Fish as appropriate.
• Ah gotcha, that'll do it! Be careful about whether you need to center and/or scale, though -- PCA is almost always done on centered data (most functions will do this automatically to inputted data), so you may need to center and/or scale your input matrix Fish to get the results you expect. – Izzy Jan 14 at 3:31