title: Error in eval(expr, envir, enclos) - contradiction?
body: <h3>Edited to give a fuller example of code and specific issue</h3>
  
  <p>I'm writing a function to produce time series plots of stock prices.  However, I'm getting the following error</p>
  
  <p>Error in eval(expr, envir, enclos) : object 'df1234' not found</p>
  
  <p>Here's an example of the function:</p>
  
  <pre><code>plot.prices &lt;- function(df1234) {
    require(ggplot2)
    g &lt;- ggplot(df1234, aes(x= as.Date(Date, format= "%Y-%m-%d"), y= df1234[, 3], 
                colour= brewer.pal(12,"Set3")[1])) + geom_point(size=1)
    g + geom_point(aes(x= date, y = df1234[, 4], 
                   colour= brewer.pal(12,"Set3")[2]), size=1)
  
    # ... code not shown...
    g
  }
  </code></pre>
  
  <p>And example data:</p>
  
  <pre><code>spy &lt;- read.csv(file= 'http://ichart.finance.yahoo.com/table.csv?s=SPY&amp;d=11&amp;e=1&amp;f=2012&amp;g=d&amp;a=0&amp;b=29&amp;c=1993&amp;ignore=.csv', header= T)
  
  plot.prices(spy) # produces error
  g &lt;- ggplot(spy, aes(x= as.Date(Date, format= "%Y-%m-%d"), y= spy[, 3], 
                colour= brewer.pal(12,"Set3")[1])) + geom_point(size=1)
    g + geom_point(aes(x= as.Date(Date), y = spy[, 4], 
                   colour= brewer.pal(12,"Set3")[2]), size=1)
  ## does not produce error
  </code></pre>
  
  <p>As you can see, the code is identical. I get an error if the call to ggplot() is INSIDE the function but not if the call to ggplot() is OUTSIDE the function. </p>
  
  <h3>Anyone have any idea why the seeming contradiction?</h3>