Updating data.table by inserting new rows that are different from old rows

前端 未结 3 492
面向向阳花
面向向阳花 2021-01-22 22:52

I have two data.table(dt1 & dt2). dt1 is past product data and dt2 is present product data. I want to create a third data.table that inserts new rows from dt2 into dt1 only

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-22 23:41

    Another alternative is to only rbind the subset of the data which is different (avoids the creation of one big data.table which contains dt1 and dt2)

    dt3 <- rbind(dt1, setDT(dt2)[!dt1, on=c("Product", "Level", "Color")])
    dt3[order(Product, ReviewDate),]
    

提交回复
热议问题