Re: [R] RES: applying function to multiple columns of a matrix

2011-07-12 Thread Federico Calboli
I just realised that: apply(matrix(1:dim(my.data)[2], nrow =3), 2, function(x){my.function(my.data[,x])}) is the simplest possible method. bw F On 12 Jul 2011, at 14:44, Filipe Leme Botelho wrote: > Hi Frederico. I would keep the data as it is, create two small vectors > referring to the r

[R] RES: applying function to multiple columns of a matrix

2011-07-12 Thread Filipe Leme Botelho
Hi Frederico. I would keep the data as it is, create two small vectors referring to the ranges and use a mapply (as a sapply but with multiple variables) for the function. Hope the example below is helpful, although as usual someone out there will have a better solution for it. > dta <- c() > f