An easier and more logical way to express "elements of object X not in object Y"; %in% and %nin% are wrappers for match; returns a vector of booleans.

x %nin% table

Arguments

x

vector or NULL: the values to be matched. Long Vectors are suppored.

table

vector or NULL: the values to be matched against. Long vectors are not supported.

See also

%in%, match

Examples

1:10 %nin% 5:15
#> [1] TRUE TRUE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
which(1:10 %nin% 5:15)
#> [1] 1 2 3 4