title: R: Dynamically update formula
body: <p>How can I dynamically update a formula?</p>
  
  <p>Example:</p>
  
  <pre class="lang-r prettyprint-override"><code>myvar &lt;- "x"
  
  update(y ~ 1 + x, ~ . -x)
  # y ~ 1 (works as intended)
  
  update(y ~ 1 + x, ~ . -myvar)
  # y ~ x (doesn't work as intended)
  
  update(y ~ 1 + x, ~ . -eval(myvar))
  # y ~ x (doesn't work as intended)
  </code></pre>