Choose groups to keep/drop in data.table

后端 未结 3 484
别跟我提以往
别跟我提以往 2020-12-21 06:41

How can I drop/keep groups according to a condition in data.table? Is there a better method than adding a new column, then filtering on that column and removing it?

3条回答
  •  既然无缘
    2020-12-21 07:10

    I am sure that it is not the best solution, but that works.

    dt[a%in% dt[, a[2%in%b], by=a][, a],]
    

提交回复
热议问题