i have a question relating to deleting rows in data.table How can i delete rows in data.table which only contain NA values? There are some solutions here but it only works when it contains only numeric value. But my data also contains characteristic value so i can not use something like sumRows. Thanks for your help
Asked
Active
Viewed 1,128 times
2 Answers
4
We can use Reduce
with is.na
dt[dt[,!Reduce(`&`, lapply(.SD, is.na))]]
data
dt <- data.table(col1 = c(1, NA, 2, NA, 3), col2 = c(2, NA, 3, 4, 5))

akrun
- 874,273
- 37
- 540
- 662