[R] function to collapse data by factor/group
Alexander Nervedi
alexnerdy at hotmail.com
Sun May 7 20:01:58 CEST 2006
Hi
is there an R equivalent of the Stata collpase command?
suppose i have:
classes <- 1:5
schools <- letters[1:5]
stud <- 1:10
dat <- expand.grid(School = schools, Grade = classes, Student.ID = stud)
with(dat, table(Student.ID, School))
dat$marks <- rnorm(nrow(dat), 50, 25)
I want to get the mean score by school and class while the data is at the
school-class-student level. I could write something up but I was wondering
if there is already something otu there.
Alex
More information about the R-help
mailing list