How can I perform a “setdiff” merge using data.table?

后端 未结 2 540
暖寄归人
暖寄归人 2021-01-12 09:36

Say I have two tables:

library(data.table)
set.seed(1)

tab1 <- data.table(
  let = rep(letters[1:2], each = 3),
  num = rep(1:3, 2),
  val = rnorm(6),
           


        
2条回答
  •  不知归路
    2021-01-12 10:18

    In this case, it's equivalent to an anti join:

    tab1[!tab2, on=c("let", "num")]
    

    But setdiff() would only the first row for every let,num. This is marked for v1.9.8, FR #547.

提交回复
热议问题