Hi, I am wondering if anybody has a simpler solution to calculate the following:
> ma a b [1,] 1 4 [2,] 2 3 [3,] 3 2 [4,] 4 5 > pa [,1] [,2] [,3] [,4] a 1 2 3 4 b 4 3 2 5 > diag(ma%*%pa) [1] 17 13 13 41 I only want to calculate the product of the row of the first matrix and the corresponding column of the second matrix (instead of other columns). However, what I did was to multiply these two and then extract the diagonal components. Is there a simpler way to do this in R? (ma and pa may not be the same matrix.) Thanks! ______________________________________________________ Donate to the Hurricane Katrina relief effort. ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html