title: How can I combine multiple ggplot2 elements into the return of a function?
body: <p>If I try to manually compose some elements of a <code>ggplot2</code> plot, it works just fine:</p>
  
  <pre><code>&gt; p &lt;- ggplot(aes(x = mpg, y = hp), data = mtcars)
  &gt; p + geom_vline(xintercept = 20) + geom_point(data = mtcars)
  </code></pre>
  
  <p>But if I try to bundle some of the composition into a function, I get an error:</p>
  
  <pre><code>&gt; myFunction &lt;- function() {
  +   return(
  +     geom_vline(xintercept = 20) + geom_point(data = mtcars)
  +   )
  + }
  &gt; p &lt;- ggplot(aes(x = mpg, y = hp), data = mtcars)
  &gt; p + myFunction()
  Error in geom_vline(xintercept = 20) + geom_point(data = mtcars) : 
    non-numeric argument to binary operator
  </code></pre>
  
  <p>Am I missing something in <code>ggplot2</code> notation for properly combining <code>ggplot2</code> elements within a function body?</p>