title: Using function arguments in update.formula
body: <p>I am writing a function that takes two variables and separately regresses each of them on a set of controls expressed as a one-sided formula. Right now I'm using the following to make the formula for one of the regressions, but it feels a bit hacked-up:</p>
  
  <pre><code>foo &lt;- function(x, y, controls) {
      cl &lt;- match.call()
      xn &lt;- cl[["x"]]
      xf &lt;- as.formula(paste(xn, deparse(controls)))
  }
  </code></pre>
  
  <p>I'd prefer to do this using <code>update.formula()</code>, but of course <code>update.formula(controls, x ~ .)</code> and <code>update.formula(controls, as.name(x) ~ .)</code> don't work. What should I be doing?</p>