A Ezhil <[EMAIL PROTECTED]> writes:

> 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?

How about 

dim(M) <- c(4,248,74)
mn <- apply(M, c(2,3), mean)
 
(Yes, this is a bit confusing and easy to get wrong...)

-- 
   O__  ---- Peter Dalgaard             Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark          Ph:  (+45) 35327918
~~~~~~~~~~ - ([EMAIL PROTECTED])                  FAX: (+45) 35327907

______________________________________________
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

Reply via email to