R data.table选择行(i)必须使用括号? [在data.table< = 1.9.4]

时间:2015-03-27 10:23:50

标签: r data.table

为什么这两个data.table命令的结果不同?

DT[num == 1, .N] # returns wrong result

DT[(num == 1), .N] # returns correct result

numdata.table DT

中的数字列

编辑:sessionInfo()

R version 3.1.2 (2014-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
 [1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C         LC_TIME=C            LC_COLLATE=C        
 [5] LC_MONETARY=C        LC_MESSAGES=C        LC_PAPER=C           LC_NAME=C           
 [9] LC_ADDRESS=C         LC_TELEPHONE=C       LC_MEASUREMENT=C     LC_IDENTIFICATION=C 

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] data.table_1.9.4

通过命名空间加载(而不是附加): [1] Rcpp_0.11.4 chron_2.3-45 plyr_1.8.1 reshape2_1.4.1 stringr_0.6.2 tools_3.1.2