title: Multiple functions in a single tapply or aggregate statement
body: <p>Is it possible to include two functions within a single tapply or aggregate statement?</p>
  
  <p>Below I use two tapply statements and two aggregate statements: one for mean and one for SD.<br>
  I would prefer to combine the statements.</p>
  
  <pre><code>my.Data = read.table(text = "
    animal    age     sex  weight
         1  adult  female     100
         2  young    male      75
         3  adult    male      90
         4  adult  female      95
         5  young  female      80
  ", sep = "", header = TRUE)
  
  with(my.Data, tapply(weight, list(age, sex), function(x) {mean(x)}))
  with(my.Data, tapply(weight, list(age, sex), function(x) {sd(x)  }))
  
  with(my.Data, aggregate(weight ~ age + sex, FUN = mean)
  with(my.Data, aggregate(weight ~ age + sex, FUN =   sd)
  
  # this does not work:
  
  with(my.Data, tapply(weight, list(age, sex), function(x) {mean(x) ; sd(x)}))
  
  # I would also prefer that the output be formatted something similar to that 
  # show below.  `aggregate` formats the output perfectly.  I just cannot figure 
  # out how to implement two functions in one statement.
  
    age    sex   mean        sd
  adult female   97.5  3.535534
  adult   male     90        NA
  young female   80.0        NA
  young   male     75        NA
  </code></pre>
  
  <p>I can always run two separate statements and merge the output.  I was just hoping there might be
  a slightly more convenient solution.</p>
  
  <p>I found the answer below posted here: <a href="https://stackoverflow.com/questions/7406461/apply-multiple-functions-to-column-using-tapply">Apply multiple functions to column using tapply</a></p>
  
  <pre><code>f &lt;- function(x) c(mean(x), sd(x))
  do.call( rbind, with(my.Data, tapply(weight, list(age, sex), f)) )
  </code></pre>
  
  <p>However, neither the rows or columns are labeled.  </p>
  
  <pre><code>     [,1]     [,2]
  [1,] 97.5 3.535534
  [2,] 80.0       NA
  [3,] 90.0       NA
  [4,] 75.0       NA
  </code></pre>
  
  <p>I would prefer a solution in base R.  A solution from the <code>plyr</code> package was posted at the link above.  If I can add the correct row and column headings to the above output, it would be perfect. </p>