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. Anyway, what is the use of
roll=TRUE in this case (there are no missing values with nomatch=0)?
That has the same column name issue but in the result this time and may
be easier to work around in the meantime. I've assumed you've already
tried grouping by x1 and using .SD.
Grouping might work in combination with calling a function on each group
that constructs all valid combinations of ids in the group. Not
straightforward to ensure compatible values over all groups, but I'll
dig into it. Thanks for the suggestion!
Andreas
--
Andreas Borg
Medizinische Informatik
UNIVERSITÄTSMEDIZIN
der Johannes Gutenberg-Universität
Institut für Medizinische Biometrie, Epidemiologie und Informatik
Obere Zahlbacher Straße 69, 55131 Mainz
www.imbei.uni-mainz.de
Telefon +49 (0) 6131 175062
E-Mail: [email protected]
Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen.
Wenn Sie nicht der
richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren
Sie bitte sofort den
Absender und löschen Sie diese Mail. Das unerlaubte Kopieren sowie die
unbefugte Weitergabe
dieser Mail und der darin enthaltenen Informationen ist nicht gestattet.
_______________________________________________
datatable-help mailing list
[email protected]
https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help