We can check the presence of element(s) of an object in another object using the function is.element() in R language.
is.element(x, y)
The is.element() function takes the following mandatory parameter values:
x: This is the element that we want to search for in an R object.y: This is an R object containing elements.The is.element() function returns a logical value (true or false) indicating whether the element appears in y.
# creating an R object of elementsA <- c(1, 3, 4, 5, 6, 7, 8)# to check to see if 2 is an element of Ais.element(2, A)
In the code above,
A containing numerical elements.2 is an element of A by using the is.element() function.