title: non-numeric argument to binary operator
body: <p>I'm attempting to create my first function in R. The function should take in a data frame, x-series from data frame, y-series from data frame, and plot a scatter plot.  Seems simple enough, but I run into trouble when I attempt to check for an optional boolean argument. </p>
  
  <h3>R Script</h3>
  
  <pre><code>plotScatterChart &lt;- function(data,x,y,scale=y,line=FALSE) {
  
      require(ggplot2)
      data$x &lt;- as.numeric(x)
      data$y &lt;- as.numeric(y)
  
      plot &lt;- ggplot(data, aes(x, y)) + 
              geom_point() +  # aes(alpha=0.3,color=scale)
              #scale_color_gradient(high="red")
  
      if(line) {
          plot &lt;- plot + geom_smooth(method="lm") 
      }
  
      ggsave(file="plot.svg", plot=plot, height=10, width=10)
  
      return(plot)
  }
  
  plotScatterChart(data=iris,x=iris$Petal.Length,y=iris$Petal.Width,line=TRUE)
  </code></pre>
  
  <h3>Error</h3>
  
  <pre><code>non-numeric argument to binary operator
  </code></pre>
  
  <h3>Extra</h3>
  
  <p>Other suggestions for improving this function are welcome. </p>