library(plyr) system.time(t4<-ddply(mydf,.(a),summarize,mean(b)))