I have a data table with three columns. The first two are a collection of the data points (categorical data that can be either A, B, or C). The third column is a concatenation o
I'm no good with data.table, so here's my answer with a data.frame:
Just sort the two CATs before pasting, making sure they're always in the same order.
dt1$merged<-apply(dt1,1,function(x) paste(sort(x),collapse=" & "))
I'm sure there's a faster way to do in with data.table, but I'm not sure how. A naive sort
added to your code came up with an error...