[R] Summing data frame columns on identical data

Hadley Wickham hadley at rice.edu
Tue Jan 18 00:10:10 CET 2011


> library(plyr)
> # Function to sum y by A-B combinations for a generic data frame
> dsum <- function(d) ddply(d, .(A, B), summarise, sumY = sum(y))

See count in plyr 1.4 for a much much faster way of doing this.

Hadley

-- 
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/



More information about the R-help mailing list