title: Lazy Evaluation: Why can't I use plot(..., xlim = c(0,1), ylim = xlim)?
body: <p>One of <code>R</code>'s greatest feature is lazy evaluation. This leads to the often encountered style that one can use an arguments as the value of another arguments. For example, in Hadley's great book on <a href="http://adv-r.had.co.nz">Advanced R</a> you see <a href="http://adv-r.had.co.nz/Functions.html#function-arguments">this example</a>:</p>
  
  <pre><code>g &lt;- function(a = 1, b = a * 2) {
    c(a, b)
  }
  g()
  #&gt; [1] 1 2
  g(10)
  #&gt; [1] 10 20
  </code></pre>
  
  <p>Now, I would like to do the same for plot with <code>xlim</code> and <code>ylim</code>, however, it is not working:</p>
  
  <pre><code>&gt; plot(1, 1, ylim = c(0,1), xlim = ylim)
  Error in plot.default(1, 1, ylim = c(0, 1), xlim = ylim) : 
    object 'ylim' not found
  &gt; plot(1, 1, xlim = c(0,1), ylim = xlim)
  Error in plot.default(1, 1, xlim = c(0, 1), ylim = xlim) : 
    object 'xlim' not found
  </code></pre>
  
  <ul>
  <li>Does anybody know why?</li>
  <li>Is there a way to still achieve this?</li>
  </ul>