title: Parallel wilcox.test using group_by and summarise
body: <p>There must be an R-ly way to call <code>wilcox.test</code> over multiple observations in parallel using group_by. I've spent a good deal of time reading up on this but still can't figure out a call to <code>wilcox.test</code> that does the job. Example data and code below, using <code>magrittr</code> pipes and <code>summarize()</code>. </p>
  
  <pre><code>library(dplyr)
  library(magrittr)
  
  # create a data frame where x is the dependent variable, id1 is a category variable (here with five levels), and id2 is a binary category variable used for the two-sample wilcoxon test
  df &lt;- data.frame(x=abs(rnorm(50)),id1=rep(1:5,10), id2=rep(1:2,25))
  
  # make sure piping and grouping are called correctly, with "sum" function as a well-behaving example function 
  df %&gt;% group_by(id1) %&gt;% summarise(s=sum(x))
  df %&gt;% group_by(id1,id2) %&gt;% summarise(s=sum(x))
  
  # make sure wilcox.test is called correctly 
  wilcox.test(x~id2, data=df, paired=FALSE)$p.value
  
  # yet, cannot call wilcox.test within pipe with summarise (regardless of group_by). Expected output is five p-values (one for each level of id1)
  df %&gt;% group_by(id1) %&gt;% summarise(w=wilcox.test(x~id2, data=., paired=FALSE)$p.value) 
  df %&gt;% summarise(wilcox.test(x~id2, data=., paired=FALSE))
  
  # even specifying formula argument by name doesn't help
  df %&gt;% group_by(id1) %&gt;% summarise(w=wilcox.test(formula=x~id2, data=., paired=FALSE)$p.value)
  </code></pre>
  
  <p>The buggy calls yield this error: </p>
  
  <pre><code>Error in wilcox.test.formula(c(1.09057358373486, 
      2.28465932554436, 0.885617572657959,  : 'formula' missing or incorrect
  </code></pre>
  
  <p>Thanks for your help; I hope it will be helpful to others with similar questions as well.</p>