set.seed(45L)
dt1= data.table(x=rep(1:2, each=10), y=sample(8,20,TRUE), key="x")
dt2 = data.table(x=1:2, y1=1:2, y2=3:4, y3=5:6, y4=7:8, key="x")
Now if I'd like to join and for each match get the count of values y >= y_i. Using by=.EACHI this is quite simple:
dt1[dt2, .(sum(y>=y1), sum(y>=y2), sum(y>=y3), sum(y>=y4)), by=.EACHI]
Having a i.SD would allow usage of:
dt1[dt2, lapply(i.SD, function(x) sum(y > x)), by=.EACHI]
Now if I'd like to join and for each match get the count of values
y >= y_i. Usingby=.EACHIthis is quite simple:Having a
i.SDwould allow usage of: