Skip to content

Instantly share code, notes, and snippets.

@Gotfrid
Created January 20, 2021 17:03
Show Gist options
  • Save Gotfrid/5662de35d4ec02467c802c14d2645767 to your computer and use it in GitHub Desktop.
Save Gotfrid/5662de35d4ec02467c802c14d2645767 to your computer and use it in GitHub Desktop.
# create two simple dt with same order
dt1 = data.table(k = c(1:10),
v1 = rnorm(10),
key = "k")
dt2 = data.table(k = c(1:10),
v2 = rnorm(10),
key = "k")
# change order of dt1
dt1 = dt1[order(v1)]
# make dt2 be of the same order as dt1
dt2[dt1[, .(k)]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment