library(data.table)
dt <- data.table(A=c(NA,3,5,0,1,2),B=c("foo","foo","foo","bar","bar","bar"))
dt
#> A B
#> 1: NA foo
#> 2: 3 foo
#> 3: 5 foo
#> 4: 0 bar
#> 5: 1 bar
#> 6: 2 bar
#simple filter
dt[,.I[A>1]]
#> [1] NA 2 3 6
dt[A>1,which=TRUE]
#> [1] 2 3 6
我希望这两个应该返回相同的结果。