Reputation: 35
I have a matrix "eps" with 2 rows and n columns. I also have a matrix B with 2 rows and 2 columns. I want to multiply the inverse of B with each column of "eps" to acquire n new matrices dimension 2x1. Then I transpose those n new matrices for dimension 1x2 and fill them in matrix U which has 2 columns and n rows.
But my code below is wrong with the message "Error: unexpected symbol in "for i"" from R. Could you please help me? Thanks a lot!
for i in 1:nrow(U){U[i,] <- t(solve(B)%*%eps[,i])}
Upvotes: 1
Views: 882
Reputation: 73265
U <- t(solve(B, eps))
and done!
Regarding the error: for (i in 1:nrow(U))
please read ?Control
.
Upvotes: 2