I would like to drop/filter rows with NA
for specific ids
.
Why doesn't the 1st approach work? The reason why I tried it is because it's more concise than the 2nd approach.
Code:
df = structure(list(id = c(1, 2, 3, 4), a = c("a", NA, NA, NA)), class = "data.frame", row.names = c(NA,
-4L))
# Remove rows with ids `2` and `3`
# 1st approach
df = df %>% filter(!id == c(2,3)) # Doesn't work
# 2nd approach
df = df %>% filter(!(id == 2 | id == 3)) # Works