Non matching alternatives and supplementary functions.
x %out% table
x %wo% table
x %wi% table
no_match(x, table)
any_match(x, table)
vector or NULL
: the values to be matched.
Long vectors are supported.
vector or NULL
: the values to be matched against.
Long vectors are not supported.
%out%
: A logical
vector of equal length of x
, table
%wo%
, %wi%
: A vector of values of x
any_match()
, no_match()
: TRUE
or FALSE
Contrast with base::match()
, base::intersect()
, and %in%
The functions of %wi%
and %wo%
can be used in lieu of intersect()
and
setdiff()
. The primary difference is that the base functions return only
unique values, which may not be a desired behavior.
1:10 %in% c(1,3,5,9)
#> [1] TRUE FALSE TRUE FALSE TRUE FALSE FALSE FALSE TRUE FALSE
1:10 %out% c(1,3,5,9)
#> [1] FALSE TRUE FALSE TRUE FALSE TRUE TRUE TRUE FALSE TRUE
letters[1:5] %wo% letters[3:7]
#> [1] "a" "b"
letters[1:5] %wi% letters[3:7]
#> [1] "c" "d" "e"
# base functions only return unique values
c(1:6,7:2) %wo% c(3,7,12) # -> keeps duplicates
#> [1] 1 2 4 5 6 6 5 4 2
setdiff(c(1:6,7:2), c(3,7,12)) # -> unique values
#> [1] 1 2 4 5 6
c(1:6,7:2) %wi% c(3,7,12) # -> keeps duplicates
#> [1] 3 7
intersect(c(1:6,7:2), c(3,7,12)) # -> unique values
#> [1] 3 7