'Why won't filter() work for filtering out multiple rows that don't equal certain characters?

I am trying to filter through bird nest boxes that were unknown if occupied or not in one column. For these unknowns, the syntax is things like "Not monitored" or "Replaced box, ready for next season!" that I want to get rid of. So I am trying to filter a new dateframe to have everything that does not equal (!=) these unknowns.

It will let me filter out one of these unknowns when I write code for just one, but it won't let me use the or argument "|" to add others in one line of code. It just doesn't filter anything. It doesn't give me an error either.

Example:

library(dplyr)

szb5 <- filter(szb4, nests_2021 != "Not Monitored") #this works and filters correctly

szb5 <- filter(szb4, nests_2020 != "Replaced box, ready for next year!" | nests_2020 != "Old location, not monitored", nests_2020 != "Not monitored") #this doesn't filter anything

The rows don't change in the new "szb5" dataframe.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source