title: tapply function with multiple groups
body: <p>trying to reshape some data tables using tapply.  Straight forward enough if you have one factor, one variable, and your desired mathematical function.  However I have some datasets where I'd like to reformat with two (or perhaps more) grouping levels.</p>
  
  <p>Consider</p>
  
  <pre><code>x&lt;-1:20 # variable
  y&lt;-factor(rep(letters[1:5], each=4)) # first grouping variable
  z&lt;-factor(rep(letters[6:7], each=10)) # second grouping variable
  tapply(x,z,sum) # summarized table for factor z
  
    f   g 
   55 155
  
  tapply(x,y,sum) # summarized table for factor y
  
   a  b  c  d  e
  10 26 42 58 74 
  </code></pre>
  
  <p>However, my desired output is would be a table that is something like:</p>
  
  <pre><code>f  f  f  f  f g  g  g  g  g
  a  b  c  d  e a  b  c  d  e
  6  8  10....etc
  </code></pre>
  
  <p>So, just trying to keep higher level grouping in tables.  Sorry if a simple question, I've looked around and can't find anything.</p>