title: Perform several t.tests simultaneously on tidy data in R
body: <p>I have a dataset that looks like the following: </p>
  
  <pre><code>id  samediff  factor  value
  1   S         give    3
  1   S         impact  4
  2   S         give    2
  2   S         impact  5   
  3   D         give    1
  3   D         impact  4
  4   D         give    3
  4   D         impact  5 
  </code></pre>
  
  <p>I would like to perform several t.tests to compare the means for each factor in the S (samediff) condition to the means for that same factor in the D (samediff) condition. </p>
  
  <p>I know I could do this in the following way: </p>
  
  <pre><code>dfgive&lt;-filter(df, factor == "give")
  t.test(value~samediff, dfgive)
  
  dfimpact&lt;-filter(df, factor == "impact")
  t.test(value~samediff, dfimpact) 
  </code></pre>
  
  <p>Is there a way to perform several t.tests in fewer lines? In the actual dataset, there are several more factors than are included here. I would like to be able to conduct all the t.tests necessary without creating separate dataframes in the same way I've shown above.  </p>