Re: [R] apply (or similar preferred) for multiple columns

2011-07-12 Thread Gabor Grothendieck
On Tue, Jul 12, 2011 at 5:27 AM, Dimitris.Kapetanakis wrote: > Dear all, > > I would like to use the apply or a similar function belonging to this > family, but applying for each column (or row) but let say for each q > columns. For example I would like to apply a function FUN for the first q > co

Re: [R] apply (or similar preferred) for multiple columns

2011-07-12 Thread Daniel Malter
Probably not the most elegant, but a workable solution. Assume you have a matrix x of dimensions 10 x 10. Assume further you want to calculate the mean for each successive block of two columns. One way to do this is to create a matrix that indicates the column numbers from/to which to apply the fun

[R] apply (or similar preferred) for multiple columns

2011-07-12 Thread Dimitris.Kapetanakis
Dear all, I would like to use the apply or a similar function belonging to this family, but applying for each column (or row) but let say for each q columns. For example I would like to apply a function FUN for the first q columns of matrix X then for q+1:2*q and so on. If I do apply (X, 2, FUN)