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
?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)
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]]
___
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
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
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
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,
7 matches
Mail list logo