title: performing t-test on dplyr group_by columns
body: <p>In extension to <a href="https://stackoverflow.com/questions/31133492/apply-list-of-functions-on-list-of-columns-based-on-different-combinations">this</a> question, How can I incorporate <code>t.test</code> for each column(<code>con1</code>,<code>con2</code>) there based on the resulting two groups(<code>A</code>,<code>B</code>) in the new data frame i.e., <code>t.test</code>(<code>df$con1[df$cat1=='A']</code>,<code>df$con1[df$cat1=='B']</code>) and <code>t.test</code>(<code>df$con2[df$cat1=='A']</code>,<code>df$con2[df$cat1=='B']</code>) </p>
  
  <pre><code># Random generation of values for categorical data
  set.seed(33)
  df &lt;- data.frame(cat1 = sample( LETTERS[1:2], 100, replace=TRUE ), 
                  cat2 = sample( LETTERS[3:5], 100, replace=TRUE ),
                  cat3 = sample( LETTERS[2:4], 100, replace=TRUE ),
                  con1 = runif(100,0,100),
                  con2 = runif(100,23,45))
  
  # Introducing null values 
  df$con1[c(23,53,92)] &lt;- NA
  df$con2[c(33,46)] &lt;- NA
  
  # List of functions 
  df %&gt;% group_by(cat1) %&gt;% 
   summarise_each(funs(mean(., na.rm = TRUE),
                       sd(., na.rm = TRUE)), 
                  starts_with("con"))
  </code></pre>
  
  <p>And in this case with groups corresponding to <code>A</code>,<code>B</code> i.e., <code>t.test</code>(<code>df$con1[df$cat1=='A' &amp; df$cat2=='C']</code>,<code>df$con1[df$cat1=='B' &amp; df$cat2=='C']</code>), ... <code>t.test</code>(<code>df$con2[df$cat1=='A' &amp; df$cat2=='E']</code>,<code>df$con2[df$cat1=='B' &amp; df$cat2=='E']</code>)</p>
  
  <pre><code>df %&gt;% group_by(cat1, cat2) %&gt;% 
       summarise_each(funs(mean(., na.rm = TRUE),
                           sd(., na.rm = TRUE)), 
                      starts_with("con"))
  </code></pre>