Skip to content
Prev 66498 / 398513 Next

summing values by group

you could use '?by()', e.g.,

dat <- data.frame(CAT=sample(letters[1:5], 100, TRUE), x=rnorm(100), 
y=rnorm(100), z=rnorm(100))
by(dat[sapply(dat, is.numeric)], dat$CAT, sum)
by(dat[sapply(dat, is.numeric)], dat$CAT, mean)


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/16/336899
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat/
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Larry White" <ljw1001 at gmail.com>
To: <R-help at stat.math.ethz.ch>
Sent: Thursday, March 24, 2005 5:12 PM
Subject: [R] summing values by group