For example, I have a table as follows:
DT <- data.table( A = c(1,1,1,2,2,2,3,3,3), B = c(1,2,3,1,2,3,1,2,3), key = \"A\" )
I wand to
if you only have two columns, then you could do:
unique(do.call(function(A,B)data.table(A=pmin(A,B),B=pmax(A,B)),DT)) A B 1: 1 1 2: 1 2 3: 1 3 4: 2 2 5: 2 3 6: 3 3