Fast EXISTS in data.table

后端 未结 2 1719
伪装坚强ぢ
伪装坚强ぢ 2021-02-10 05:16

What is the fastest way to check if a value exists in a data.table?. Suppose that

  • dt is a data.table of n columns with k columns being the key
  • keys is a l
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-10 05:43

    How about the base R idiom:

    any(my.value %in% my.vector)
    

    This is not a data.table specific idiom but is quite efficient I believe.

提交回复
热议问题