Re: [R] summing array elements

2011-05-30 Thread marco milella
Thanks a lot for your hint marco 2011/5/27 Erich Neuwirth erich.neuwi...@univie.ac.at arr-1:72 dim(arr)-c(2,4,3,3) apply(arr,1:2,sum) [,1] [,2] [,3] [,4] [1,] 297 315 333 351 [2,] 306 324 342 360 apply(arr,3:4,sum) [,1] [,2] [,3] [1,] 36 228 420 [2,] 100 292

Re: [R] summing array elements

2011-05-30 Thread marco milella
Thanks a lot for your help marco 2011/5/27 Thomas Lumley tlum...@uw.edu On Fri, May 27, 2011 at 10:06 AM, marco milella vru...@gmail.com wrote: Hi to everybody I have an array with dimensions 2,4,3,3. Wanting to sum the matrices in the first two dimensions, I'm trying to use the apply

[R] summing array elements

2011-05-26 Thread marco milella
Hi to everybody I have an array with dimensions 2,4,3,3. Wanting to sum the matrices in the first two dimensions, I'm trying to use the apply function, but with no results. Have to say I'm quite new with R syntax. tx in advance marco [[alternative HTML version deleted]]

Re: [R] summing array elements

2011-05-26 Thread Thomas Lumley
On Fri, May 27, 2011 at 10:06 AM, marco milella vru...@gmail.com wrote: Hi to everybody I have an array with dimensions 2,4,3,3. Wanting to sum the matrices in the first two dimensions, I'm trying to use the apply function, but with no results. Have to say I'm quite new with R syntax. Tell

Re: [R] summing array elements

2011-05-26 Thread Erich Neuwirth
arr-1:72 dim(arr)-c(2,4,3,3) apply(arr,1:2,sum) [,1] [,2] [,3] [,4] [1,] 297 315 333 351 [2,] 306 324 342 360 apply(arr,3:4,sum) [,1] [,2] [,3] [1,] 36 228 420 [2,] 100 292 484 [3,] 164 356 548 apply(arr,1:2,sum) will sum all elements arr(i1,i2,..) for each single