1

I know you can filter for values you want to keep using %in% but what if I wanted to remove a few values at once and keep the rest?

For example, I have a bunch of rows with transects numbers I want to keep but I want to remove all rows with transects 137, 22, and 141.

jschlener
  • 21
  • 4

1 Answers1

1

Example with iris data, removing some values of Sepal.Length:

library(tidyverse)
remove_values = c(5.1, 4.9, 4.7)
iris %>% 
  filter(!(Sepal.Length %in% remove_values))
tauft
  • 546
  • 4
  • 13
  • 1
    I understand you may have included the internal parentheses after `!` for clarity, but worth noting that they aren't strictly necessary. – Dan Adams Aug 20 '22 at 01:04