title: Passing function argument to formula
body: <p>I'm trying to understand why</p>
  
  <pre><code>foo = function(d,y,x) {
      fit = with(d, lm(y ~ x))
  }
  foo(myData, Y, X)
  </code></pre>
  
  <p>won't work, where for instance</p>
  
  <pre><code>myData = data.frame(Y=rnorm(50), X=runif(50))
  </code></pre>
  
  <p>The bit that seems tricky to me is passing the arguments <code>x</code> and <code>y</code> to a formula, as in <code>lm(y ~ x)</code>.</p>