Home > database >  How to use filter != to exclude rows with either characters within the same column?
How to use filter != to exclude rows with either characters within the same column?

Time:08-26

I have

df %>% filter(column_A != "Char1", column_A != "Char2", column_B != "Char3")

which works but doesn't work when I do this

df %>% filter((column_A != "Char1" || "Char2"), column_B != "Char3")

How do I correct this syntax?

CodePudding user response:

You are searching for the operator %in%

df %>% filter(!column_A %in% c("Char1", "Char2"), column_B != "Char3")
  • Related