Hadley turned me on to the plyr package and I find myself using it all the time to do \'group by\' sort of stuff. But I find myself having to always rename the resulting col
This seems to work:
> groupAcres <- ddply(mydata, c("state"), function(df) c(myName=sum(df$acres))) > groupAcres state myName 1 A 56.87973 2 B 57.84451 3 C 52.82415
Use summarise (or summarize):
groupAcres <- ddply(mydata, "state", summarise, myName = sum(acres))