> a<-matrix(c(1:9),3,3) > a [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 > a[3,]*a[,3] # I expect 1x1 matrix as resul
This is an R FAQ. You need to do a[3,,drop = FALSE].
a[3,,drop = FALSE]
You're confusing element-by-element multiplication and matrix multiplication (see ?"*"). You want %*%:
?"*"
%*%
> a[3,]%*%a[,3] [,1] [1,] 150