Hi R,
I have a list of matrices. I need to get the sum of all the matrices in
the list.
Example:
a=b=c=d=matrix(1:4,2,2)
l=list(a,b,c,d)
I need:
a+b+c+d
[,1] [,2]
[1,]4 12
[2,]8 16
Something like do.call(+,l) is not working...why is this?
I may not
- Original Message -
From: Shubha Vishwanath Karanth [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, June 04, 2008 4:53 PM
Subject: [R] sum of unknown number of matrices
Hi R,
I have a list of matrices. I need to get the sum of all the matrices
in
the list.
Example
Shubha Vishwanath Karanth wrote:
I need:
a+b+c+d
[,1] [,2]
[1,]4 12
[2,]8 16
Something like do.call(+,l) is not working...why is this?
Because do.call constructs a function call with the elements of l as
arguments, so you end up with:
+(1:4, 1:4, 1:4, 1:4)
but
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
On
Behalf Of Shubha Vishwanath Karanth
Sent: June-04-08 10:54 AM
To: [EMAIL PROTECTED]
Subject: [R] sum of unknown number of matrices
Hi R,
I have a list of matrices. I need to get the sum of all the matrices
[mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 04, 2008 8:49 PM
To: Shubha Vishwanath Karanth
Cc: [EMAIL PROTECTED]
Subject: Re: [R] sum of unknown number of matrices
Shubha Vishwanath Karanth wrote:
I need:
a+b+c+d
[,1] [,2]
[1,]4 12
[2,]8 16
Something like
G'day Shubha,
On Wed, 4 Jun 2008 20:23:35 +0530
Shubha Vishwanath Karanth [EMAIL PROTECTED] wrote:
Something like do.call(+,l) is not working...why is this?
Well, as the error message says, + is either a unary or a binary
operator, i.e. it takes either one or two arguments, but not more.
I
6 matches
Mail list logo