title: How do ggplot2 arguments work?
body: <p>In R with <code>ggplot2</code>, these two lines seem to do the same thing:</p>
  
  <pre><code>qplot(data=diamonds, carat, price)
  qplot(data=diamonds, get("carat"), get("price"))
  </code></pre>
  
  <p>but I don't understand how they work... </p>
  
  <p>How does R understand what <code>carat</code> refers to in the first case and what <code>get("carat")</code> refers to in the second? If I just try to access <code>carat</code> or <code>get("carat")</code> on their own I get (unsurprisingly)</p>
  
  <pre><code>&gt; carat
  Error: object 'carat' not found
  &gt; get("carat")
  Error in get("carat") : object 'carat' not found
  </code></pre>
  
  <p>Under the hood, how does <code>ggplot2</code> set up the bindings such that these elegant calling semantics "just work" and more specifically, how would I go about implementing this sort thing myself? I've tried to read the source but am having trouble understanding it.</p>