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.
Data set one
dim(foo1) # 600 / 2
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
Data set two
dim(foo2) # 60.000 / 2
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
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)
This is my beginning 'solution' that doesn't work:
for(i in 1:nrow(foo1)){
foo1$new_column[i] <-sum(foo2$Count[which(
foo2$Time >= foo2$Start[i] &
foo2$Time <= foo2$End[i])])
}