title: Is there a way to pass dplyr's `do` function a vector of additional arguments?
body: <p>I was curious if there was a way to pass dplyr's <code>do</code> function a vector of additional arguments which would be applied to each group in turn? Consider, for example, if we wanted to group the <code>mtcars</code> dataset by its <code>cyl</code> variable and apply the <code>head</code> function to the resulting groups (one for 4, 6, and 8 respectively) with n = 1 for the 4 group, n = 2 for the 6 group, and n = 3 for the 8 group, combining the final results in a single dataframe.</p>
  
  <p>I can accomplish this using <code>mapply</code> as follows:</p>
  
  <pre><code>temp &lt;- mtcars %&gt;% 
    split(mtcars$cyl) %&gt;%
    mapply(FUN = head, x = ., n = 1:3, SIMPLIFY = FALSE)
  rbind(temp[[1]], temp[[2]], temp[[3]])
  </code></pre>
  
  <p>I was curious if there was an equivalent way of doing this with dplyr? I got as far as below, but was stymied as to how to pass <code>head</code> an additional argument representing the number of rows we would like to select:</p>
  
  <pre><code># only selects first row of each group
  mtcars %&gt;%
    group_by(cyl) %&gt;%
    do(data.frame(head(x = ., n = 1)))
  
  # throws an error because n expects a single number
  mtcars %&gt;%
    group_by(cyl) %&gt;%
    do(data.frame(head(x = ., n = 1:3)))
  </code></pre>