title: Implementing mutate within a function called with variables
body: <p>I'd like to call a function several times with different variables, each time setting a value to a new variable in the data frame. Here is my failed attempt. I appreciate any help!</p>
  <pre><code>dat &lt;- tibble(score1 = runif(10), score2 = score1 * 2)
  
  call_mutate_with_vars &lt;- function(df, var1, var2, var3) {
    df &lt;- 
      df %&gt;%
      mutate({{var3}} := ifelse({{var1}} &gt;= {{var2}},0,{{var2}} - {{var1}}))
    df
  }
  
  call_mutate_with_vars(dat,&quot;score1&quot;,&quot;score2&quot;,&quot;newscore&quot;)
  </code></pre>
  <p>I receive this error:</p>
  <pre><code>Error: Problem with `mutate()` column `newscore`.
  i `newscore = ifelse(&quot;score1&quot; &gt;= &quot;score2&quot;, 0, &quot;score2&quot; - &quot;score1&quot;)`.
  x non-numeric argument to binary operator
  Run `rlang::last_error()` to see where the error occurred.
  </code></pre>