If group_times threshold is minutes (e.g. 5 minutes), we aren't grouping to the nearest hour if we are nearer to next hour than e.g. 55 minutes.
Example:
DT <- data.table(
idate = as.IDate('2018-12-12'),
itime = as.ITime(
c('01:00', '01:02', '00:58',
'03:00', '03:02', '02:59',
'05:00', '05:01', '04:58')
)
)
group_times(DT, c('idate', 'itime'), threshold = '5 minutes')
| idate |
itime |
minutes |
timegroup |
| 2018-12-12 |
01:00:00 |
0 |
1 |
| 2018-12-12 |
01:02:00 |
0 |
1 |
| 2018-12-12 |
00:58:00 |
60 |
2 |
| 2018-12-12 |
03:00:00 |
0 |
3 |
| 2018-12-12 |
03:02:00 |
0 |
3 |
| 2018-12-12 |
02:59:00 |
60 |
4 |
| 2018-12-12 |
05:00:00 |
0 |
5 |
| 2018-12-12 |
05:01:00 |
0 |
5 |
| 2018-12-12 |
04:58:00 |
60 |
6 |
We'd expect here to have 3 timegroups (on 1:00, 3:00 and 5:00).
We end up with 6.
Note: this kind of rolling to the nearest hour was addressed for the less frequent, rolling 24 hours to the next day.
Regardless, still miss grouping row 3 and row 9.
DT <- data.table(
idate = as.IDate(
c('2018-12-12','2018-12-12', '2018-12-12',
'2018-12-12','2018-12-12', '2018-12-13',
'2018-12-13','2018-12-13', '2018-12-13')),
itime = as.ITime(
c('22:00', '22:02', '21:58',
'23:58', '23:59', '0:01',
'2:00', '2:01', '1:58'))
)
group_times(DT, c('idate', 'itime'), threshold = '5 minutes')
| idate |
itime |
minutes |
timegroup |
| 2018-12-12 |
22:00:00 |
0 |
1 |
| 2018-12-12 |
22:02:00 |
0 |
1 |
| 2018-12-12 |
21:58:00 |
60 |
2 |
| 2018-12-12 |
23:58:00 |
60 |
3 |
| 2018-12-12 |
23:59:00 |
60 |
3 |
| 2018-12-13 |
00:01:00 |
0 |
3 |
| 2018-12-13 |
02:00:00 |
0 |
4 |
| 2018-12-13 |
02:01:00 |
0 |
4 |
| 2018-12-13 |
01:58:00 |
60 |
5 |
If
group_timesthreshold is minutes (e.g. 5 minutes), we aren't grouping to the nearest hour if we are nearer to next hour than e.g. 55 minutes.Example:
We'd expect here to have 3 timegroups (on 1:00, 3:00 and 5:00).
We end up with 6.
Note: this kind of rolling to the nearest hour was addressed for the less frequent, rolling 24 hours to the next day.
Regardless, still miss grouping row 3 and row 9.