title: using non-standard evaluation with formula
body: <p>I'm creating a package that uses <a href="http://adv-r.had.co.nz/Computing-on-the-language.html" rel="nofollow noreferrer">non-standard evaluation</a> to keep track of the meaning of columns. The package passes a data frame among functions, which do various things do the same set of columns. Nonstandard evaluation works great for this:</p>
  
  <pre><code>my_select &lt;- function(df, xcol, ycol) {
      new_df &lt;- dplyr::select(df, !!xcol, !!ycol)
      new_df
  }
  my_select(mtcars, quo(wt), quo(mpg))
  </code></pre>
  
  <p>However, I'd like a function that works with a formula:</p>
  
  <pre><code>my_lm &lt;- function(df, xcol, ycol) {
      new_lm &lt;- lm(!!xcol, !!ycol, data=df)
      new_lm
  }
  my_lm(mtcars, quo(wt), quo(mpg)
  </code></pre>
  
  <p>returns <code>Error in !xcol : invalid argument type</code>. I've tried all sorts of combinations of <code>quo()</code>, <code>enquo()</code>, and <code>!!</code>, but the basic problem is that I don't know what kind of object <code>lm</code> needs.</p>