[R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps a function I can call? I tried using do.call(sum,listoftables) but that returns a single value. So far, it seems only a loop will do the job. TIA, DAV

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Petr Savicky
On Mon, Apr 16, 2012 at 10:28:43AM -0400, David A Vavra wrote: I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps a function I can call? I tried using do.call(sum,listoftables) but that returns a single value. So far, it seems only a

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Greg Snow
Look at the Reduce function. On Mon, Apr 16, 2012 at 8:28 AM, David A Vavra dava...@verizon.net wrote: I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps a function I can call? I tried using do.call(sum,listoftables) but that returns a

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
Define sum . Do you mean you want to get a single sum for each array? -- get marginal sums for each array? -- get a single array in which each value is the sum of all the individual values at the position? Due thought and consideration for those trying to help by formulating your query carefully

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
suggestion for using reduce seems in order but as yet I'm unfamiliar with the function. DAV -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 12:42 PM To: Greg Snow Cc: David A Vavra; r-help@r-project.org Subject: Re: [R] Effeciently sum 3d

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
] On Behalf Of Petr Savicky Sent: Monday, April 16, 2012 11:07 AM To: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Mon, Apr 16, 2012 at 10:28:43AM -0400, David A Vavra wrote: I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Look at the Reduce function. On Mon, Apr 16, 2012 at 8:28 AM, David A Vavra dava...@verizon.net wrote: I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps a function I can call? I

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 12:42 PM To: Greg Snow Cc: David A Vavra; r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Define sum . Do you mean you want to get a single sum for each array? -- get marginal sums

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David Winsemius
] On Behalf Of Petr Savicky Sent: Monday, April 16, 2012 11:07 AM To: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Mon, Apr 16, 2012 at 10:28:43AM -0400, David A Vavra wrote: I have a large number of 3d tables that I wish to sum Is there an efficient way to do this? Or perhaps

Re: [R] Effeciently sum 3d table

2012-04-16 Thread William Dunlap
: Monday, April 16, 2012 11:35 AM To: 'Bert Gunter' Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Thanks Gunter, I mean what I think is the normal definition of 'sum' as in: T1 + T2 + T3 + ... It never occurred to me that there would be a question. I have gotten

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
DAV -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 3:07 PM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table David: 1. My first name is Bert. 2. It never occurred to me that there would be a question

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David Winsemius
Cheers, DAV -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org ] On Behalf Of Petr Savicky Sent: Monday, April 16, 2012 11:07 AM To: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Mon, Apr 16, 2012 at 10:28:43AM

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
[mailto:dwinsem...@comcast.net] Sent: Monday, April 16, 2012 3:26 PM To: David A Vavra Cc: 'Petr Savicky'; r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Apr 16, 2012, at 2:43 PM, David A Vavra wrote: Thanks Petr, I'm after T1 + T2 + T3 + ... Which would be one number ... i.e

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
, USE.NAMES = USE.NAMES)) } environment: 0x7fb3442553c8 DAV -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 3:07 PM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table David: 1. My first name is Bert

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
...@tibco.com] Sent: Monday, April 16, 2012 3:26 PM To: David A Vavra; 'Bert Gunter' Cc: r-help@r-project.org Subject: RE: [R] Effeciently sum 3d table Example in partial code: Env - CreatEnv() # my own function Assign('final',T1-T1,envir=env) L-listOfTables lapply(L,function(t

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
Dunlap [mailto:wdun...@tibco.com] Sent: Monday, April 16, 2012 3:26 PM To: David A Vavra; 'Bert Gunter' Cc: r-help@r-project.org Subject: RE: [R] Effeciently sum 3d table Example in partial code: Env - CreatEnv() # my own function Assign('final',T1-T1,envir=env) L-listOfTables

Re: [R] Effeciently sum 3d table

2012-04-16 Thread William Dunlap
that sentence. Bill Dunlap Spotfire, TIBCO Software wdunlap tibco.com From: David A Vavra [mailto:dava...@verizon.net] Sent: Monday, April 16, 2012 1:20 PM To: William Dunlap Cc: r-help@r-project.org Subject: RE: [R] Effeciently sum 3d table Thanks Bill, For reasons that aren't important here

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
]),        SIMPLIFY = SIMPLIFY, USE.NAMES = USE.NAMES)) } environment: 0x7fb3442553c8 DAV -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 3:07 PM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table David: 1. My

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
(),        PACKAGE = base) ... etc. -Original Message- From: Bert Gunter [mailto:gunter.ber...@gene.com] Sent: Monday, April 16, 2012 4:13 PM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table For purposes of clarity only... On Mon, Apr 16, 2012

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David Winsemius
, April 16, 2012 3:26 PM To: David A Vavra Cc: 'Petr Savicky'; r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Apr 16, 2012, at 2:43 PM, David A Vavra wrote: Thanks Petr, I'm after T1 + T2 + T3 + ... Which would be one number ... i.e. the result you originally said you did

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Greg Snow
- From: Greg Snow [mailto:538...@gmail.com] Sent: Monday, April 16, 2012 11:54 AM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Look at the Reduce function. On Mon, Apr 16, 2012 at 8:28 AM, David A Vavra dava...@verizon.net wrote: I have a large number

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David Winsemius
- From: Greg Snow [mailto:538...@gmail.com] Sent: Monday, April 16, 2012 11:54 AM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Look at the Reduce function. On Mon, Apr 16, 2012 at 8:28 AM, David A Vavra dava...@verizon.net wrote: I have a large number

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David Winsemius
Message- From: William Dunlap [mailto:wdun...@tibco.com] Sent: Monday, April 16, 2012 3:26 PM To: David A Vavra; 'Bert Gunter' Cc: r-help@r-project.org Subject: RE: [R] Effeciently sum 3d table Example in partial code: Env - CreatEnv() # my own function Assign('final',T1-T1,envir

Re: [R] Effeciently sum 3d table

2012-04-16 Thread Bert Gunter
; 'Bert Gunter' Cc: r-help@r-project.org Subject: RE: [R] Effeciently sum 3d table Example in partial code: Env - CreatEnv() # my own function Assign('final',T1-T1,envir=env) L-listOfTables lapply(L,function(t) {    final - get('final',envir=env) + t    assign('final',final

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
, April 16, 2012 4:55 PM To: David A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table On Apr 16, 2012, at 4:04 PM, David A Vavra wrote: even now you _could_ be clearer I fail to see why it's unclear. I'm after T1 + T2 + T3 + ... Which would be one number ... i.e

Re: [R] Effeciently sum 3d table

2012-04-16 Thread David A Vavra
A Vavra Cc: r-help@r-project.org Subject: Re: [R] Effeciently sum 3d table Here is a simple example: mylist - replicate(4, matrix(rnorm(12), ncol=3), simplify=FALSE) A - Reduce( `+`, mylist ) B - mylist[[1]] + mylist[[2]] + mylist[[3]] + mylist[[4]] all.equal(A,B) [1] TRUE Basically what