RE: [R] applying a function over an array

2005-05-18 Thread McGehee, Robert
This will do it. a - array(1:12, c(4, 3)) d - function(a,b,c) {a+b+c} apply(a, 1, function(x) do.call(d, sapply(x, list))) [1] 15 18 21 24 -Original Message- From: BJ [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 18, 2005 9:10 AM To: r-help@stat.math.ethz.ch Subject: [R] applying a

Re: [R] applying a function over an array

2005-05-18 Thread Gabor Grothendieck
On 5/18/05, BJ [EMAIL PROTECTED] wrote: Is there a way to apply a function with several arguements over an array? For instance if you had a function d-function(a,b,c) {a+b+c} and a 4,3 array, could you apply the function over each line of the array? tapply seems to only allow one argument, and

Re: [R] applying a function over an array

2005-05-18 Thread Gabor Grothendieck
On 5/18/05, Gabor Grothendieck [EMAIL PROTECTED] wrote: On 5/18/05, BJ [EMAIL PROTECTED] wrote: Is there a way to apply a function with several arguements over an array? For instance if you had a function d-function(a,b,c) {a+b+c} and a 4,3 array, could you apply the function over each line