title: ggplot using second data source for error bars fails
body: <p>This is a follow-on to a previous question about getting some custom error bars.</p>
  
  <ol>
  <li>The look of the plot is how I need it, so don't worry about commenting in solely in regards to that (happy to hear opinions attached to other help though)</li>
  <li>Because these plots are generated in a loop, and the error bars are actually only added if a condition is met, I cant simply merge all the data up front, so assume for the purpose of this exercise the plot data and errorbar data are from different dfs.</li>
  </ol>
  
  <p>I have a <code>ggplot</code>, to which I attempt to add some error bars using a different dataframe. When I call the plot, it says that it cannot find the y values from the parent plot, even though I'm just trying to add error bars using new data. I know this has to be a syntax error but I am stumped...</p>
  
  <p>First lets generate data and the plot</p>
  
  <pre><code>library(ggplot2)
  library(scales)
  
  # some data
  data.2015 = data.frame(score = c(-50,20,15,-40,-10,60),
                         area = c("first","second","third","first","second","third"),
                         group = c("Findings","Findings","Findings","Benchmark","Benchmark","Benchmark"))
  
  data.2014 = data.frame(score = c(-30,40,-15),
                         area = c("first","second","third"),
                         group = c("Findings","Findings","Findings"))
  
  # breaks and limits
  breaks.major = c(-60,-40,-22.5,-10, 0,10, 22.5, 40, 60)
  breaks.minor = c(-50,-30,-15,-5,0, 5, 15,30,50) 
  limits =c(-70,70)
  
  # plot 2015 data
  ggplot(data.2015, aes(x = area, y = score, fill = group)) +
    geom_bar(stat = "identity", position = position_dodge(width = 0.9)) +
    coord_flip() +
    scale_y_continuous(limit = limits, oob = squish, minor_breaks = breaks.minor, 
                       breaks = breaks.major)
  </code></pre>
  
  <p>Calling the plot (c) produces a nice plot as expected, now lets set up the error bars and attempt to add them as a new layer in the plot "c"</p>
  
  <pre><code># get the error bar values
  alldat = merge(data.2015, data.2014, all = TRUE, by = c("area", "group"), 
                 suffixes = c(".2015", ".2014"))
  alldat$plotscore = with(alldat, ifelse(is.na(score.2014), NA, score.2015))
  alldat$direction = with(alldat, ifelse(score.2015 &lt; score.2014, "dec", "inc"))
  alldat$direction[is.na(alldat$score.2014)] = "absent"
  
  #add error bars to original plot
  c &lt;- c+
    geom_errorbar(data=alldat, aes(ymin = plotscore, ymax = score.2014, color = direction), 
                  position = position_dodge(width = .9), lwd = 1.5, show.legend = FALSE)
  </code></pre>
  
  <p>When I call c now, I get </p>
  
  <pre><code>"Error in eval(expr, envir, enclos) : object 'score' not found"
  </code></pre>
  
  <p>Why does it look for data.2015$score when I just want it to overlay the <code>geom_errorbar</code> using the second alldat dataframe?</p>
  
  <p>EDIT* I've tried to specify the ymin/ymax values for the error bars using alldata$plotscore and alldat$score.2014 (which I am sure is bad practice), it plots, but the bars are in the wrong positions/out of order with the plot (e.g. swapped around, on the benchmark bars instead, etc.)</p>