当i
containsNA
时,不返回该特定行。我不确定这是预期的行为还是它?
require(data.table)
x = data.table(a=c(NA, 1:3, NA))
x[a>0]
a
1: 1
2: 2
3: 3
x[!(a>0)]
a
1: NA
2: NA
x[a<0]
Empty data.table (0 rows) of 1 col: a
x[!(a<0)]
a
1: NA
2: 1
3: 2
4: 3
5: NA
> sessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] data.table_1.8.8