Hi,
I've run into the following unexpected issue...
I am trying to join sales to shifts here by timestamp.
sales = data.table( sale_id = 1:5, sale_ts = (1:5)*5 )
shifts = data.table( shift_id= 21:23, shift_start = c(1,10,15), shift_end=c(9,14,19) )
sales[shifts, on=.(sale_ts>=shift_start, sale_ts<shift_end) ]
returns
sale_id sale_ts sale_ts.1 shift_id
1: 1 1 9 21
2: 2 10 14 22
3: 3 15 19 23
This is misleading because the timestamps that are returned are not sale timestamps at all, but shift timestamps. I realize that reversing the code to do shifts[sales ... will give more appropriate results, but I'm likely not the only one confused by the behavior of the former formulation and possibly not the only one for whom this behavior resulted in some headache.
Thanks!
Hi,
I've run into the following unexpected issue...
I am trying to join sales to shifts here by timestamp.
returns
This is misleading because the timestamps that are returned are not sale timestamps at all, but shift timestamps. I realize that reversing the code to do
shifts[sales ...will give more appropriate results, but I'm likely not the only one confused by the behavior of the former formulation and possibly not the only one for whom this behavior resulted in some headache.Thanks!