This helper function checks if elements
of one vector are not found in another vector.
Arguments
- a
vector or NULL: the values to be matched.
- b
vector or NULL: the values to be matched against.
Value
A logical vector, indicating if a match was
not located for each element of a. The values
are TRUE or FALSE and never NA.
Examples
c(1,2,3) %not_in% c(3,4,5,6,7)
#> [1] TRUE TRUE FALSE
library(dplyr)
PlantGrowth %>% filter(group %not_in% c("ctrl", "trt2"))
#> weight group
#> 1 4.81 trt1
#> 2 4.17 trt1
#> 3 4.41 trt1
#> 4 3.59 trt1
#> 5 5.87 trt1
#> 6 3.83 trt1
#> 7 6.03 trt1
#> 8 4.89 trt1
#> 9 4.32 trt1
#> 10 4.69 trt1