[datatable-help] Column names after self join

Matthew Dowle mdowle at mdowle.plus.com
Thu Mar 31 10:23:35 CEST 2011


"Andreas Borg" <andreas.borg at unimedizin-mainz.de> wrote in message 
news:4D94364F.1040407 at unimedizin-mainz.de...
> 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)






More information about the datatable-help mailing list