[datatable-help] datatable roll="next" takes 150 times longer than findInterval

Gabor Grothendieck ggrothendieck at gmail.com
Thu Feb 6 12:55:41 CET 2014


On Wed, Feb 5, 2014 at 10:42 AM, Arunkumar Srinivasan
<aragorn168b at gmail.com> wrote:
> Seems like the "by-without-by" is what's slowing things down:
>
> require(data.table)
> dtx <- data.table(x=which(X), key="x")
> dty <- data.table(y=which(Y), key="y")
> dtx[, x1 := x]
> dty[, y1 := y]
> system.time(ans <- dty[dtx, roll="nearest"][, abs(x1-y1)])
>    user  system elapsed
>   1.321   0.076   1.396
> system.time(ans2 <- flodel(x,y))
>    user  system elapsed
>   0.936   0.044   0.977
>
> identical(ans, ans2) # [1] TRUE

What will the code look like after the explicit by-without-by feature is added?

-- 
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com


More information about the datatable-help mailing list