[R] row*matrix
smajor
semajor at ncsu.edu
Sat Aug 6 22:35:26 CEST 2011
Hi all, I'm learning R. I'm used to Matlab and am having the following issue:
I define a column vector and matrix and then multiply them. The result is
not what I expect:
v2 <- c(0,1,0)
M <- cbind(c(1,4,7),c(2,5,8),c(3,6,9))
M*v2
[,1] [,2] [,3]
[1,] 0 0 0
[2,] 4 5 6
[3,] 0 0 0
I expect the result to be a column, specifically the 2nd column of M.
Now I want to left multiply the matrix by a row vector, and I get errors:
t(v2)*M
Error in t(v2) * M : non-conformable arrays
> V2 <- t(v2)
> V2*M
Error in V2 * M : non-conformable arrays
I would expect to get the 2nd row of M as an output.
Why am I not getting a column for the first case? Why is the second case
causing errors? Any help would be greatly appreciated. I can get the
--
View this message in context: http://r.789695.n4.nabble.com/row-matrix-tp3724023p3724023.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list