Hello,
I have a simple task: I have a large dataset, and I want to filter rows where subset of columns ALL contain NA (not if any of them contains NA).
data <- data.frame(x1 = c(4, 1, NA, 7, 8, 1), # Create example data
x2 = c("A", NA, NA, "XX", "YO", "YA"),
x3 = c(1, 0, NA, 1, 1, NA)
x4 = c("A", "B", "C", "XX", "YO", "YA") )
I want to remove rows where all from x1, x2, x3 contain NAs and leave out x4 while filtering (not my variable of interest in terms of NAs).
it's easy to do when you want to filter rows if any of the columns contain NA but I couldn't find a decent solution for this one.