[R] prcomp(): How do I multiply two matrices
T.Riedle
tr206 at kent.ac.uk
Fri Oct 7 20:24:00 CEST 2016
Dear R-users,
I am trying to do a principal components analysis using the attached data. My code looks as follows. I want to calculate the time series of the principal components (PC) . To this end, I transform the coefficients and the data into matrices and employ a matrix multiplication but it does not work.
data<-equityfunds[,-1]
PC<-prcomp(data)
coef1<-PC$rotation
data<-as.matrix(data)
PC1<-coef1 %*% data
This is the error message I get.
Error in coef1 %*% data : non-conformable arguments
So, what is wrong with my code? How do I multiply the coefficients with the observations?
More information about the R-help
mailing list