probably you want ?rowsum(); I hope it helps. 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: "Werner Wernersen" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Friday, May 12, 2006 11:48 AM Subject: [R] optimal way to compute matrix subtotals? > Hi! > > I have large matrices, one column per variable and I have a vector > of factors / grouping symbols. Then I am computing subtotals for the > groups but it takes pretty long and thus I wanted to ask if there is > a better way to do it or if this is already the best way: > subTotals <- function(x, groupvec) > do.call("rbind",lapply(split(x,groupvec),colSums,na.rm=T)) > > > Thanks reading my question and any hints! > Werner > > > --------------------------------- > > [[alternative HTML version deleted]] > > ______________________________________________ > [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
