title: How to superimpose a line graph on a barplot in ggplot2
body: <pre><code>df2
            Year variable     value   pos
   1  2001-04-01 Purchase   4471.05  TRUE
   2  2002-04-01 Purchase   5084.00  TRUE
   3  2003-04-01 Purchase      0.00  TRUE
   4  2004-04-01 Purchase      0.00  TRUE
   5  2005-04-01 Purchase      0.00  TRUE
   6  2006-04-01 Purchase    740.00  TRUE
   7  2007-04-01 Purchase    720.00  TRUE
   8  2008-04-01 Purchase  13510.00  TRUE
   9  2009-04-01 Purchase 104480.34  TRUE
   10 2010-04-01 Purchase  85399.39  TRUE
   11 2011-04-01 Purchase  78799.05  TRUE
   12 2012-04-01 Purchase 142271.84  TRUE
   13 2013-04-01 Purchase 164240.00  TRUE
   14 2014-04-01 Purchase  54579.00  TRUE
   15 2015-04-01 Purchase     10.00  TRUE
   16 2016-04-01 Purchase  88124.00  TRUE
   17 2001-04-01     Sale  23795.10  TRUE
   18 2002-04-01     Sale  35418.45  TRUE
   19 2003-04-01     Sale  53401.52  TRUE
   20 2004-04-01     Sale  41598.01  TRUE
   21 2005-04-01     Sale   2899.24  TRUE
   22 2006-04-01     Sale   4652.71  TRUE
   23 2007-04-01     Sale   5845.26  TRUE
   24 2008-04-01     Sale   7587.17  TRUE
   25 2009-04-01     Sale   9932.03  TRUE
   26 2010-04-01     Sale   9931.45  TRUE
   27 2011-04-01     Sale  11574.75  TRUE
   28 2012-04-01     Sale   8186.81  TRUE
   29 2013-04-01     Sale  10737.00  TRUE
   30 2014-04-01     Sale   2577.00  TRUE
   31 2015-04-01     Sale  63428.00  TRUE
   32 2016-04-01     Sale  35800.00  TRUE
   33 2001-04-01      Net -19324.05 FALSE
   34 2002-04-01      Net -30334.59 FALSE
   35 2003-04-01      Net -53401.52 FALSE
   36 2004-04-01      Net -41598.01 FALSE
   37 2005-04-01      Net  -2899.24 FALSE
   38 2006-04-01      Net  -3912.71 FALSE
   39 2007-04-01      Net  -5125.38 FALSE
   40 2008-04-01      Net   5922.83  TRUE
   41 2009-04-01      Net  94548.32  TRUE
   42 2010-04-01      Net  75467.93  TRUE
   43 2011-04-01      Net  67224.30  TRUE
   44 2012-04-01      Net 134086.03  TRUE
   45 2013-04-01      Net 153503.00  TRUE
   46 2014-04-01      Net  16675.00  TRUE
   47 2015-04-01      Net -63418.00 FALSE
   48 2016-04-01      Net  52324.00  TRUE
  </code></pre>
  
  <p>Created a side by side barplot for rows 33 to 48:</p>
  
  <pre><code>library(ggplot2) #development version
  
  p&lt;-ggplot(df2[33:48,], aes(x=Year, y=value, fill=pos)) + 
     geom_bar(stat='identity', position='identity') + ggtitle("OMO (Rs'crores)\n") + theme(plot.title = element_text(lineheight=.8, face="bold",colour = "darkred",hjust =0.5,vjust = 2,size = 9)) + labs(x = "\nYear", y = "Rs crores\n",caption="Sources:Data is from RBI site")+scale_y_continuous(limits = c(-65000,200000),breaks =c(-60000,-30000,0,30000,60000,90000,120000,150000,180000,180000)) + scale_x_date(date_breaks = "2 year",date_labels = "%Y") 
  p
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/RlxMf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RlxMf.png" alt="enter image description here"></a></p>
  
  <p>I want to add (overlay) the rows 1 to 16 and 17 to 32 as 2 separate line plots on the above bargraph:</p>
  
  <p>I tried this:</p>
  
  <p>Adding the first line (variable=="purchase")
      p + geom_line(df2[1:16],aes(x=Year, y=value))
      Error: ggplot2 doesn't know how to deal with data of class uneval</p>
  
  <p>Where am I going wrong?</p>