title: Two sample t-test in a dataframe using R
body: <p>I made a <code>data</code> as follows:</p>
  <pre><code>data&lt;-data.frame(weight=c(78,89,90,45,57,89,67,56,78,50),
                   height=c(170,158,162,190,193,190,167,169,170,175),
                   bmi=c(23,24,35,19,25,29,30,34,32,31),
                   disease=c(0,1,0,0,0,0,1,1,0,0))
  </code></pre>
  <p>What I want to do is two sample t test. Two groups are divided by disease.
  So, I made the <code>data</code> into two groups like this:</p>
  <pre><code>y0&lt;-subset(data,disease==0)
  y1&lt;-subset(data,disease==1)
  </code></pre>
  <p>I want to do t-test for all variables.
  I think I can do like this:</p>
  <pre><code>t.test(y0$weight,y1$weight)
  t.test(y0$height,y1$height)
  t.test(y0$bmi,y1$bmi)
  </code></pre>
  <p>However, in my actual data, there are so many variables so that I cannot write the code as above. I want to do t-test for all variables using the position of the column. My expectation is to get a nice table including all the t values and p-values so that I can easily convert into a csv file.</p>