Hi all,
I am trying to multiply each column of a matrix such to have a unique resulting
vector with length equal to the number of rows of the original matrix. In short
I would like to do what prod(.) function in Matlab does, i.e.
A -matrix(c(1:10),5,2)
V = A[,1]*A[,2]
Thank you
Graziano
Try
apply(A, 1, prod)
I hope it helps.
Best,
Dimitris
On 2/20/2012 4:21 PM, Graziano Mirata wrote:
Hi all,
I am trying to multiply each column of a matrix such to have a unique resulting
vector with length equal to the number of rows of the original matrix. In short
I would like to do
On 20-Feb-2012 Graziano Mirata wrote:
Hi all,
I am trying to multiply each column of a matrix such to have
a unique resulting vector with length equal to the number of
rows of the original matrix. In short I would like to do what
prod(.) function in Matlab does, i.e.
A -matrix(c(1:10),5,2)
[See at end]
On 20-Feb-2012 Ted Harding wrote:
On 20-Feb-2012 Graziano Mirata wrote:
Hi all,
I am trying to multiply each column of a matrix such to have
a unique resulting vector with length equal to the number of
rows of the original matrix. In short I would like to do what
prod(.)
On Mon, Feb 20, 2012 at 09:33:28PM -, Ted Harding wrote:
[...]
Unfortunately, there seems to be no equivalent for products
(e.g. rowProds). But you can define one:
rowProds - function(X){ apply(X,1,FUN=prod) }
rowProds(A)
# [1] 6 14 24 36 50
Even then, the result is
5 matches
Mail list logo