look at ?rowMeans; you can also use "apply(mat, 1, mean)" but rowMeans() is better.
Best, Dimitris ---- Dimitris Rizopoulos Ph.D. Student Biostatistical Centre School of Public Health Catholic University of Leuven Address: Kapucijnenvoer 35, Leuven, Belgium Tel: +32/(0)16/336899 Fax: +32/(0)16/337015 Web: http://www.med.kuleuven.be/biostat/ http://www.student.kuleuven.be/~m0390867/dimitris.htm ----- Original Message ----- From: "A Ezhil" <[EMAIL PROTECTED]> To: "r-help" <[email protected]> Sent: Monday, May 29, 2006 1:24 PM Subject: [R] newbie question: ROW average > 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 > > ______________________________________________ > [email protected] mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! > http://www.R-project.org/posting-guide.html > Disclaimer: http://www.kuleuven.be/cwis/email_disclaimer.htm ______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
