I would like too summarize one column by another, which I know how to do, using either ddply or aggregate...But, I want to also add groups within my grouping variable to summarize the data in a custom fashion, see below:
##Create Data
year<-c(2008,2008,2008,2008,2009,2009,2009,2010,2010,2010,2010,2011,2011,2011,2011,2011)
catch<-c(1,2,0,1,1,0,1,0,1,2,1,0,1,1,1,0)
df<-data.frame(year,catch)
##I know how to aggregate by year:
yearlyAVcap<-ddply(df,~year,summarise,mean=mean(catch),sd=sd(catch))
##But I'd like to have 2008,2009,2010 summarized together and 2011 on it's own (i,e two groups- 1=2008,2009,2010 ; 2=2011)