I want to remove the lines from a data.table that only contain NAs.
> tab = data.table(A = c(1, NA, 3), B = c(NA, NA, 3))
> tab
A B
1: 1 NA
2: NA NA
3: 3 3
Normally I would do it with apply(dat, 1, ...)
which unfortunately does not work on a data.table but it leads me to this inelegant solution:
> tab[apply(as.data.frame(tab), 1, function(x) !all(is.na(x))), ]
A B
1: 1 NA
2: 3 3
How can this be achieved the fastest way without knowing the column names?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…