title: Specific Matching two dates in two data frames
body: <p>I want to have the sum() of counts (rows) between a specific day. I found some solutions on stack, but the point is that my second data frame is much bigger then data frame one. </p>
  
  <p><em>Data set one</em> </p>
  
  <p>dim(foo1) # 600  / 2 </p>
  
  <pre><code>Start                      End
  2017-10-24 22:33:59   2017-10-24 22:43:59
  2017-11-13 06:34:59   2017-11-13 06:44:59
  2017-11-13 06:52:00   2017-11-13 07:02:00
  2017-11-13 07:16:59   2017-11-13 07:26:59
  2017-11-13 07:35:59   2017-11-13 07:45:59
  </code></pre>
  
  <p><em>Data set two</em></p>
  
  <p>dim(foo2) # 60.000 / 2 </p>
  
  <pre><code>Count           Time
  1              2017-10-01 13:45:02
  1              2017-10-01 12:53:23
  1              2017-10-01 12:20:56
  1              2017-10-01 12:31:12
  </code></pre>
  
  <p><strong>I want the sum, of all the rows (Count) from foo2, appearing between the Start and End date in foo1). Result should be Foo1 + new_column (containing counts)</strong></p>
  
  <p>This is my beginning 'solution' that doesn't work: </p>
  
  <pre><code>for(i in 1:nrow(foo1)){
    foo1$new_column[i] &lt;-sum(foo2$Count[which( 
      foo2$Time &gt;= foo2$Start[i] &amp;
        foo2$Time &lt;= foo2$End[i])]) 
  }
  </code></pre>