title: adding row/column total data when aggregating data using plyr and reshape2 package in R
body: <p>I create aggregate tables most of the time during my work using the flow below:</p>
  
  <pre><code>set.seed(1)
  temp.df &lt;- data.frame(var1=sample(letters[1:5],100,replace=TRUE),
                        var2=sample(11:15,100,replace=TRUE))
  temp.output &lt;- ddply(temp.df,
                       c("var1","var2"),
                       function(df) {
                         data.frame(count=nrow(df))
                       })
  temp.output.all &lt;- ddply(temp.df,
                           c("var2"),
                           function(df) {
                             data.frame(var1="all",
                                        count=nrow(df))
                           })
  
  temp.output &lt;- rbind(temp.output,temp.output.all)
  temp.output[,"var1"] &lt;- factor(temp.output[,"var1"],levels=c(letters[1:5],"all"))
  temp.output &lt;- dcast(temp.output,formula=var2~var1,value.var="count",fill=0)
  </code></pre>
  
  <p>I start feeling silly to writing the "boilerplate" code every time to include the row/column total when I create a new aggregate table, is there some way for skipping it?</p>