Re: [R] Vector multiplication

2010-10-17 Thread Duncan Murdoch
Ron Michael wrote: Is there any operator in R, which will multiply each possible combination of the elements of 2 vectors? Suppose I have 2 vectors (1,2) and (1,2,3). If I multiply those 2, I should get:(1,2,3,2,4,6) See ?outer. For example, as.vector(outer(1:3, 1:2)) (but the results are

Re: [R] Vector multiplication

2010-10-17 Thread jim holtman
?outer > outer(1:2, 1:3, "*") [,1] [,2] [,3] [1,]123 [2,]246 > On Sun, Oct 17, 2010 at 3:25 AM, Ron Michael wrote: > Is there any operator in R, which will multiply each possible combination of > the elements of 2 vectors? Suppose I have 2 vectors (1,2) and (1,2,3)

[R] Vector multiplication

2010-10-17 Thread Ron Michael
Is there any operator in R, which will multiply each possible combination of the elements of 2 vectors? Suppose I have 2 vectors (1,2) and (1,2,3). If I multiply those 2, I should get:(1,2,3,2,4,6) Thanks, [[alternative HTML version deleted]] ___

Re: [R] Vector multiplication

2010-03-17 Thread Duncan Murdoch
On 17/03/2010 2:03 PM, Kaspar Bernet wrote: Hi, this may sound stupid (and it probably is), but I can't seem to find out how to multiply each element of a vector with each element of another vector where the result would be a matrix of dim[length(vectorOne),length(vectorTwo)] without using loops

Re: [R] Vector multiplication

2010-03-17 Thread Peter Alspach
Tena koe Kaspar ?outer outer(b, a) or b %o% a HTH Peter Alspach > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-boun...@r- > project.org] On Behalf Of Kaspar Bernet > Sent: Thursday, 18 March 2010 7:03 a.m. > To: r-help@r-project.org > S

Re: [R] Vector multiplication

2010-03-17 Thread Henrique Dallazuanna
Try this: b %o% a On Wed, Mar 17, 2010 at 3:03 PM, Kaspar Bernet wrote: > Hi, > > this may sound stupid (and it probably is), but I can't seem to find out how > to multiply each element of a vector with each element of another vector > where the result would be a matrix of > dim[length(vector

[R] Vector multiplication

2010-03-17 Thread Kaspar Bernet
Hi, this may sound stupid (and it probably is), but I can't seem to find out how to multiply each element of a vector with each element of another vector where the result would be a matrix of dim[length(vectorOne),length(vectorTwo)] without using loops. example: if a -> c(1,2,3) b -> c(4,5,