Try this: rowsum(mat, gl(nrow(mat)/4, 4)) / 4
On 5/29/06, A Ezhil <[EMAIL PROTECTED]> wrote: > Hi, > > I am new to R programming. I have a 992 x 74 matrix. I > would like to form a new matrix by averging each 4 > rows > from the original one. How can I use 'apply' instead > of usual mean inside the nested for loop? > > Thanks in advance. > > regards, > ezhil > > ______________________________________________ > R-help@stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html