Skip to content

Instantly share code, notes, and snippets.

@stephlocke
Created February 16, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephlocke/667ce7f84406f7094587 to your computer and use it in GitHub Desktop.
Save stephlocke/667ce7f84406f7094587 to your computer and use it in GitHub Desktop.
foverlaps multiple column check
library(data.table)
x<-data.table(a=c(1,2),a1=c(1,2),
b=c(1,2),b1=c(1,2),
c=c(1,2),c1=c(1,2))
y<-data.table(mina=0,maxa=3,
minb=0,maxb=3,
minc=0,maxc=3)
## Does work
setkey(y,mina,maxa)
setkey(x,a,a1)
foverlaps(x,y, which=TRUE)
## Doesn't work
setkey(y,mina,maxa,minb,maxb)
setkey(x,a,a1,b,b1)
foverlaps(x,y, which=TRUE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment