title: How to replicate a ddply behavior that uses a custom function with dplyr?
body: <p>I'm trying to replace all my <code>plyr</code> calls with <code>dplyr</code>. There are still a few snags and one of them is with the <code>group_by</code> function. I imagine it acts the same way as the second <code>ddply</code> argument and does a split, apply and combine based on the grouping variables I list. But that doesn't appear to be the case. Here is a rather trivial example.</p>
  
  <p>Let's define a silly function</p>
  
  <pre><code>mm &lt;- function(x) return(x[1:5, ])
  </code></pre>
  
  <p>Now we can split the species in the <code>iris</code>dataset like so and apply this function to each piece.</p>
  
  <pre><code>ddply(iris, .(Species), mm)
  </code></pre>
  
  <p>This works as intended. However, when I try the same with <code>dplyr</code>, it doesn't work as expected. </p>
  
  <pre><code>iris %&gt;% group_by(Species) %&gt;% mm
  </code></pre>
  
  <p>What am I doing wrong?</p>