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

foverlaps() should be easier to do point-to-interval join #3721

Open
MichaelChirico opened this issue Jul 23, 2019 · 0 comments
Open

foverlaps() should be easier to do point-to-interval join #3721

MichaelChirico opened this issue Jul 23, 2019 · 0 comments
Labels
non-equi joins rolling, overlapping, non-equi joins top request One of our most-requested issues

Comments

@MichaelChirico
Copy link
Member

From SE: https://codereview.stackexchange.com/questions/224705
via Twitter: https://twitter.com/Voovarb/status/1153432914878537729

ppc = 'Pacific/Pitcairn'
x <- data.table(
  TagID = c(20161L, 23055L, 45428L, 2627L),
  DateTimePST = .POSIXct(c(1415481096, 1380768444, 1474560076, 1511384035), ppc),
  Receiver = c(102140L, 112568L, 112568L, 121907L)
)

y <- data.table(
  Station = c("YBAAG4", "YBAAG4", "YBCSSW", "YBCSSW", "YBBCD", "YBAWW"),
  Receiver = c(102140L, 102140L, 112568L, 112568L, 121907L, 121907L),
  Start = .POSIXct(c(1464979020, 1409256300, 1369945920, 1470761034, 1505494980, 1409246700), ppc)),
  End = .POSIXct(c(1473357300, 1421878500, 1382638020, 1479838293, 1513282440, 1421871360), ppc),
  key=c('Receiver', 'Start', 'End')
)

The intent of the following seems pretty clear:

foverlaps(x, y, by.x = c('Receiver', 'DateTimePST', 'DateTimePST'), type = 'within')

But for now we have to resort to defining a dummy column:

x [ , end := DateTimePST]
foverlaps(x, y, by.x = c('Receiver', 'DateTimePST', 'end'), type = 'within')
@jangorecki jangorecki added the non-equi joins rolling, overlapping, non-equi joins label Apr 6, 2020
@jangorecki jangorecki removed the High label Jun 3, 2020
@MichaelChirico MichaelChirico added the top request One of our most-requested issues label Apr 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
non-equi joins rolling, overlapping, non-equi joins top request One of our most-requested issues
Projects
None yet
Development

No branches or pull requests

2 participants