grapes-notin-grapes: The inverse of %in%

Description Usage Arguments Details Value Examples

Description

%notin% tells you which values of vector x are not in vector y.

Usage

1
x %notin% y

Arguments

x

A vector

y

A vector

Details

Although this function can be called as `%notin%`(x, y), the intended use is like the function %in%: similar to x %in% y, this function's supposed use is x %notin% y. Vector types (more formally: modes) don't need to match (see last example).

Value

A vector of of booleans with the length of vector x. TRUE indicates that the particular element of x is not in y, FALSE indicates that the element of x is in y.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
c(1,2,3) %notin% c(0,2,4) # returns TRUE FALSE TRUE
# compare to:
c(1,2,3) %in% c(0,2,4) # returns FALSE TRUE FALSE

c(1,2) %notin% c(0,2,4) # returns TRUE FALSE
# versus (vectors changed place, hence, result adapts to length of x):
c(0,2,4) %notin% c(1,2) # returns TRUE FALSE TRUE

c('Hello', 'world') %notin% unlist(strsplit('The world is not enough', ' ')) # TRUE FALSE
c('Hello', 'world') %notin% c(1,2,3,4,5) # returns TRUE TRUE. Vector types don't need to match.

guf documentation built on March 26, 2020, 5:51 p.m.