Skip to contents

Check if entry is in vector

Usage

x %nin% table

Arguments

x

vector entry

table

table of items to check

Value

a boolean value to indicate if entry is present

Examples

5 %nin% c(1:10) #FALSE
#> [1] FALSE
5 %nin% c(11:20) #TRUE
#> [1] TRUE

x = "a"
if(x %nin% letters) x

# let's say we are trying to exclude numbers from a vector
vector_num1 <- number(9, max.digits = 5, seed = 1) #simulate 9 numbers
vector_num1 #values
#> [1] 66608 31292 86624 83615 55450 88461 80323 85229 93467
vector_num1[vector_num1 %nin% c(83615,85229)]#return values not 83615 or 85229
#> [1] 66608 31292 86624 55450 88461 80323 93467