Re: [R] row*matrix

2011-08-06 Thread R. Michael Weylandt
By default, R operations on matrices, vectors, etc are elementwise like .* in Matlab. If you want matrix multiplication use %*% Hope this helps and good luck with R! Feel free to write back if I can help further. Michael Weylandt On Aug 6, 2011, at 4:35 PM, smajor wrote: > Hi all, I'm lea

Re: [R] row*matrix

2011-08-06 Thread Rolf Turner
You need to learn that R syntax is not the same as Matlab syntax. If you want to use R, learn R. Read the basic introductory material, readily available from the R web site. In particular R treats multiplication --- i.e. "*" --- as multiplication. Arrays are multiplied entry by entry when they

Re: [R] row*matrix

2011-08-06 Thread Joshua Wiley
Hi, You are using the regular multiplication operator, when you want the matrix multiplication operator. Compare: > M * v2 [,1] [,2] [,3] [1,]000 [2,]456 [3,]000 > M %*% v2 [,1] [1,]2 [2,]5 [3,]8 See ?"*" and ?"%*%" HTH, Josh On Sat,

Re: [R] row*matrix

2011-08-06 Thread David Winsemius
On Aug 6, 2011, at 4:35 PM, smajor wrote: 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] [

[R] row*matrix

2011-08-06 Thread smajor
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,]000 [2,]456 [3,]