如果没有行匹配选择,如何在data.table(< = 1.9.4)中禁止打印

时间:2015-06-21 09:27:18

标签: r data.table

当我使用dt[colA=='x'&colB=='y', mycol:=y]之类的语法并且没有符合条件的行时,我会打印整个dt。有没有办法抑制此输出或以某种方式禁用它?

示例:

dt = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)
dt[x=='j',y:=5] # works fine, nothing is printed
dt[x=='j'&v==10,y:=5] # dt is printed
dt[x=='j'|v==10,y:=5] # dt is printed

0 个答案:

没有答案