Hi,

I want to extract the groups from a data table without doing anything else, i.e. pretty much the same as calling 'unique'. The following does not work:

> dt <- data.table(x=c(0,1,0,1), y=c(1,0,1,0))
> dt
    x y
[1,] 0 1
[2,] 1 0
[3,] 0 1
[4,] 1 0
> setkey(dt, x, y)
> dt[,,by=list(x,y)]
Fehler in `[.data.table`(dt, , , by = list(x, y)) :
 'by' is supplied but not j

My workaround is to add a dummy column with a fixed value which I drop later:

> dt[,1,by=list(x,y)][,list(x,y)]
    x y
[1,] 0 1
[2,] 1 0

Is there a more elegant way to achieve this? Or would it be possible to change the behaviour to allow 'by' without a j-expression (in which case my post account as a feature request)?

Anyway, thanks to the developers for this great package!

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

Reply via email to