"Andreas Borg" <[email protected]> wrote in message 
news:[email protected]...
> Hi Matthew,
>
> thanks for the reply.
>
>> The example data seems a little too cut down but if I understand
>> correctly then this idiom might be better :
>>
>>
>>> setkey(dt,x1,id)
>>> dt[J(x1,id-1,id,x2),roll=TRUE,nomatch=0]
>>>
>>      x1 id x2 id.1 x2.1
>> [1,]  a  1  1    2    2
>>
>
> That would not be sufficient because in a larger world example
> the ids of a pair can differ by more than one.

Sounds like you haven't fully understood rolling join. You
described an equi-join (if you *don't* specify roll=TRUE).

> Anyway, what is the use of roll=TRUE in this case (there are no missing 
> values with nomatch=0)?

nomatch applies after the rolling join has been done.  The rolling join 
itself
may return NA (in this example for the rows which don't have a prior id)




_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help

Reply via email to