title: Error when using apply and t-test
body: <p>I can't find the bug in my code, and/or the flaw in my logic. I have a matrix, <code>X</code>, of 0's and 1's and a vector <code>y</code> of continuous values and I want to do a 2 sample t-test in <code>R</code> where the rows of <code>X</code> indicate the different groups of <code>y</code>. </p>
  
  <p>For example:</p>
  
  <pre><code>x = matrix(rbinom(60,1,.5),ncol=10)
  y = abs(rnorm(ncol(x)))
  
  apply(x,1,function(x,y=y)t.test(y[x==1],y[x==0]))
  </code></pre>
  
  <p>So using this code I would have expected to get 6 t-tests where each row of <code>X</code> corresponds to the two groups of <code>y</code>. However, I get this error when I run my code:</p>
  
  <pre><code> Error in t.test(y[x == 1], y[x == 0]) : 
    promise already under evaluation: recursive default argument reference or earlier problems? 
  </code></pre>
  
  <p>Can someone explain the error and modify my code to get what I want. </p>