Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

odd time handling in group_times #3

Open
robitalec opened this issue Nov 29, 2018 · 2 comments
Open

odd time handling in group_times #3

robitalec opened this issue Nov 29, 2018 · 2 comments
Labels
priority: medium type: enhancement new features, improvements

Comments

@robitalec
Copy link
Member

group_times can't group odd time thresholds e.g. 2 hour threshold when times are 1am, 3am, 5am... 11pm.

This is because group_times considers the threshold in the context of 24 hours, and a two hour threshold would then group times to 0, 2, 4, 6...

Is there a way around this? Provide an 'offset' argument? Or just make sure it is clear in the vignettes and documentation?

A current workaround is using threshold = '1 hour' which will at least group to 0,1,2,3, ...

@robitalec robitalec added priority: medium type: enhancement new features, improvements labels Nov 29, 2018
@tpodgorski
Copy link

this seems to be the problem of the data I'm working with (fixes collected every two hours at uneven hours). Is setting the threshold = '5 minutes' is not enough in this case? If the "sliding window" of 5 minutes starts at midnight and scans the time series, it should capture fixes aggregated both at even and uneven hours, isn't that so? Thanks, Tomasz

@robitalec
Copy link
Member Author

Setting the threshold to '5 minutes' is sufficient when working with fixes collected on uneven hours. (Though see #5 for a recent bug fix).

For example:

DT <- data.table(
  idate = as.IDate('2018-12-12'),
  itime = as.ITime(
    c('01:00', '01:02', '01:01',
      '03:00', '03:02', '03:00',
      '05:00', '05:01', '05:01')
  )
)

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 01:01:00 0 1
2018-12-12 03:00:00 0 2
2018-12-12 03:02:00 0 2
2018-12-12 03:00:00 0 2
2018-12-12 05:00:00 0 3
2018-12-12 05:01:00 0 3
2018-12-12 05:01:00 0 3

This issue is concerned with the (possibly rare?) instance where one might want to group on uneven 2 hour fixes, with a 2 hour threshold. Not sure when one might want this, but right now - it isn't possible.

For example, this data with 2 hour fixes, on the odd hours, with the nearest hour being detected is even.

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 = '2 hours')
idate itime hours timegroup
2018-12-12 01:00:00 2 1
2018-12-12 01:02:00 2 1
2018-12-12 00:58:00 0 2
2018-12-12 03:00:00 4 3
2018-12-12 03:02:00 4 3
2018-12-12 02:59:00 2 1
2018-12-12 05:00:00 6 4
2018-12-12 05:01:00 6 4
2018-12-12 04:58:00 4 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: medium type: enhancement new features, improvements
Projects
None yet
Development

No branches or pull requests

2 participants