title: Combining data from different data.frames in ggplot2 with unexpected results
body: <p>Suppose we have the following data.frames:</p>
  
  <pre><code>dt1 &lt;- data.frame(x=1:10,y=rnorm(10),g="a",c=1)
  dt2 &lt;- data.frame(x=1:10,y=rnorm(10),g="b",c=2)
  dt &lt;- rbind(dt1,dt2)
  
  bb &lt;- data.frame(x=1:4,y=rep(-5,4))
  </code></pre>
  
  <p>The following works </p>
  
  <pre><code>qplot(x=x,y=y,data=dt,group=g,colour=c)+geom_line(aes(x=bb$x,y=bb$y),colour="black")
  </code></pre>
  
  <p>producing additional black line with data from data.frame <code>bb</code>. But with</p>
  
  <pre><code>bb &lt;- data.frame(x=1:6,y=rep(-5,6))
  </code></pre>
  
  <p>the same plotting code fails with a complaint that number of rows is different. I could merge the data.frames, i.e. expand <code>bb</code> with NAs, but I thought that the code above is valid ggplot2 code, albeit not exactly in spirit of it. So the question is why it fails? (The answer is probably related to the fact that 4 divides 20, when 6 does not, but more context would be desirable)</p>