我正在寻找在data.table中包含多个变量中的任意变量的行。我当前的代码可以工作,但有点乱: #dt contains several columns, foo1, foo2, foo3, etc that have the same possible values
bar <- ("a","b","c")
dt[foo1 %in% bar| foo2 %in% bar | foo3 %in% bar ...] 这个方法是有效的,但我想知道是否有
我获得了以下函数,可以在datatable中直接应用,但不能通过lapply应用。我想知道是否与.SD等效,它允许向函数体传递多个参数。下面的代码总是给出“未使用的参数.”sqrt(tmp)^2000000return(rep(tmp3,length(a)))DT[,doSomething(a,b,c)] # works
DT[,lapply(.SD,doSomething,a,b,c),.SDcol=c("a","b&qu