title: geom_rect and ggplot2 Error: Aesthetics must be either length 1 or the same as the data (2)
body: <p>I am trying to do something like <a href="https://stackoverflow.com/a/29649406/15485">https://stackoverflow.com/a/29649406/15485</a> but I get the error</p>
  
  <blockquote>
    <p>Error: Aesthetics must be either length 1 or the same as the data (2):
    xmin, xmax, ymin, ymax, x, y</p>
  </blockquote>
  
  <p>What does '(2)' means?</p>
  
  <p>What 'Aesthetics' are involved? I have <code>aes</code> in <code>ggplot</code> and <code>aes</code> in <code>geom_rect</code> but I have no idea about how to correct them... I am afraid I will never grasp <code>ggplot</code>...</p>
  
  <pre><code>days&lt;-rep(Sys.Date(),100)+seq(1,100)
  v&lt;-sin(as.numeric(days))
  df&lt;-data.frame(days=days,v=v)
  
  shade &lt;- data.frame(x1=c(as.Date('2017-10-15'),as.Date('2017-11-11')), 
                     x2=c(as.Date('2017-10-20'),as.Date('2017-11-13')), 
                     y1=c(-Inf,-Inf), y2=c(Inf,Inf))
  
  library(ggplot2)
  plot(ggplot(df,aes(x=days,y=v))
       +geom_line()
       +geom_rect(data=shade, 
                 mapping=aes(xmin=x1, xmax=x2, ymin=y1, ymax=y2), color='grey', alpha=0.2)
       +geom_point())
  </code></pre>