How can I efficiently bind two keyed columns into a single column of pairs that will preserve the lexicographic order of the two keys? I am interested in using 'loc' as a single (sorted) variable
dt = data.table(
loc.x = as.integer(c(1, 1, 3, 1, 3, 1)),
loc.y = as.integer(c(1, 2, 1, 2, 1, 2)),
value = letters[1:6]
)
setkey(dt, loc.x, loc.y)