title: computing T-test with help of apply function
body: <p>I have a matrix :</p>
  
  <pre><code>&gt;data
  
        A  A  A  B  B  C
  gene1 1  6 11 16 21 26
  gene2 2  7 12 17 22 27
  gene3 3  8 13 18 23 28
  gene4 4  9 14 19 24 29
  gene5 5 10 15 20 25 30
  </code></pre>
  
  <p>I want to to test whether  the mean of each gene (rows) values are different between different groups for each gene or not? I want to use T-test for it. The function should take all columns belong to group <code>A</code>, take all columns belongs to group  <code>B</code>,  take all columns belongs to group <code>C</code>,... and calculate the T-test between each groups for each genes.(every groups contains several columns)
  on implementation which I got from answer to my previews post is :</p>
  
  <pre><code> Results &lt;- combn(colnames(data), 2, function(x) t.test(data[,x]), simplify = FALSE)
   sapply(Results, "[", c("statistic", "p.value"))
  </code></pre>
  
  <p>but it does compute between all columns rather than between groups for every row. can somebody help me how to modify this code to calculate T test between groups like for my data ?</p>