I have the same question like solved here, but I have to work with data.table.
What is the best data.table-way to filter out all rows, where specific / "relevant" columns are all NA, unimportant what other "irrelevant" columns show (NA / or not).
library(data.table)
df <- data.frame('epoch' = c(1,2,3),
'irrel_2' = c(NA,4,5),
'rel_1' = c(NA, NA, 8),
'rel_2' = c(3,NA,7)
)
df
#> epoch irrel_2 rel_1 rel_2
#> 1 1 NA NA 3
#> 2 2 4 NA NA
#> 3 3 5 8 7
setDT(df)
wrong <- na.omit(df, cols = 3:4)
Created on 2023-05-25 with reprex v2.0.2
I want just row 2 to be filtered out. What would be your solution?