title: Convert a "by" object to a data frame in R
body: <p>I'm using the "by" function in R to chop up a data frame and apply a function to different parts, like this:</p>
  
  <pre><code>pairwise.compare &lt;- function(x) {
  Nright &lt;- ...
  Nwrong &lt;- ...
  Ntied &lt;- ...
  return(c(Nright=Nright, Nwrong=Nwrong, Ntied=Ntied))
  }
  Z.by &lt;- by(rankings, INDICES=list(rankings$Rater, rankings$Class), FUN=pairwise.compare)
  </code></pre>
  
  <p>The result (Z.by) looks something like this:</p>
  
  <pre><code>: 4 
  : 357 
  Nright Nwrong Ntied
       3      0     0
  ------------------------------------------------------------
  : 8 
  : 357 
  NULL
  ------------------------------------------------------------
  : 10 
  : 470 
  Nright Nwrong Ntied
       3      4     1 
  ------------------------------------------------------------ 
  : 11 
  : 470 
  Nright Nwrong Ntied
      12      4     1
  </code></pre>
  
  <p>What I would like is to have this result converted into a data frame (with the NULL entries not present) so it looks like this:</p>
  
  <pre><code>  Rater Class Nright Nwrong Ntied
  1     4   357      3      0     0
  2    10   470      3      4     1
  3    11   470     12      4     1
  </code></pre>
  
  <p>How do I do that? </p>