Given a data.table
DT<-data.table(a=c(1,2,NA,4,5), b=c(2,3,4,NA,5),c=c(1,2,3,4,5),d=c(2,3,4,5,6))
how can I do the equivalent of
DT[!is.na(a) & !is.na(b) & !is.na(c) & !is.na(d)]
in a general form without knowing any of the column names or typing out the !is.na()
for each individual column.
I could also do
DT[apply(DT,1,function(x) !any(is.na(x)))]
but I'm wondering if there's a better way still.