title: Multiple T-test in R
body: <p>I have a 94 varibles(sample+proteins+group) and 172 observations in a matrix as:</p>
  
  <pre><code>Sample   Protein1   Protein2 ... Protein92 Group
  1          1.53      3.325   ...   5.63      0
  2          2.32      3.451   ...   6.32      0
  .
  . 
  .
  103        3.24      4.21    ...   3.53      0               
  104        3.44      5.22    ...   6.78      1
  .
  .
  .
  192        6.75      4.34    ...   6.15      1
  </code></pre>
  
  <p>Some of the sample are in group 0 and some are in group 1. I want to test if there is a differences between group 0 and 1 using a t-test and I want to do it for all the proteins. I was thinking of using an apply, but I am not sure how to use it. 
  Also the names are not Protein1, protein2... , it is much longer so I would not want to have to write them all. </p>
  
  <p>I also would only like the p-value for each protein in a matrix, something like this:</p>
  
  <pre><code>Protein  p-value
  Protein1   0.00563
  Protein2   0.0640
  .
  .
  Protein92  0.610
  </code></pre>
  
  <p>Or something similar so that I after can find just the ones with a p-value lower than 0.05/92.</p>
  
  <hr>
  
  <p>Edit: </p>
  
  <p>Started working in long format this thing is not really a problem anymore:</p>
  
  <pre><code>library(tidyverse)
  
  df %&gt;%
  gather(Protein, Value,-Sample,-Group)) %&gt;%
  group_by(Protein) %&gt;%
  do(broom::tidy(t.test(Value ~ Group, data = .))) %&gt;%
  ungroup() %&gt;% 
  mutate(Adjusted_pval = p.adjust(p.value, method = "fdr"))
  </code></pre>