title: create templates using ggplot2 syntax?
body: <p>I wonder if it's possible to create a similar set of figures in ggplot2 and just change the data somehow. For instance, I can create a function to accomplish this task:</p>
  
  <pre><code>plot1 &lt;- function(data) ggplot(data) + geom_line(aes(x,y)) + theme_bw()
  plot1(data)
  plot1(newdata)
  </code></pre>
  
  <p>But is it possible to save and reuse a set of components in some manner like this? (obviously this does not work):</p>
  
  <pre><code>g &lt;- geom_line(aes(x,y)) + theme_bw()
  ggplot(data) + g
  ggplot(newdata) + g
  </code></pre>