title: passing string to ggplot function
body: <p>I would like to have a function that i could apply to any object that meets a criteria, and have a nice <code>ggplot</code> scatter plot with regression line print. </p>
  
  <p>However, i cannot generalise what i can do at the <code>REPL</code> with code. </p>
  
  <p>so i have this working: </p>
  
  <pre><code>require(ggplot2)    
  require(xts)
  set.seed(1)
  dd = xts(cbind(rnorm(10), runif(10)), order.by = Sys.Date() + 1:10)
  names(dd) &lt;- c('d1', 'd2')
  
  gp &lt;- ggplot(data = dd, 
               aes(x = d1, y = d2)) + 
          geom_point(shape=1) + 
          geom_smooth(method = lm)
  </code></pre>
  
  <p>But this fails</p>
  
  <pre><code>PointReg &lt;- function(Xts, a=1, b=2) {
      stopifnot(is.xts(Xts), 
                ncol(Xts) &gt;1)
      tempData &lt;- Xts[, c(a,b)]
      gPlot &lt;- ggplot(data = tempData, 
                  aes(x = colnames(tempData)[1],
                     y = colnames(tempData)[2])) +
              geom_point(shape=1) +
              geom_smooth(method = lm)
      gPlot
  }
  </code></pre>
  
  <p>What am i doing wrong? </p>