This is probably a very basic R question…and feel a bit bad about asking…but is there a bit of code like == or | or ! or & etc that carries out the following logical function?
if
x == any of the value of the elements/contained in vector y
then TRUE
else
FALSE
It’s actually pretty close to exactly what you said.
That can work for any length of x and y although it will throw a warning if x and y aren’t multiples of each other in length. It would be best if x and y are the same length. However, for the limited case of x being one item then
will also work. And, if you have an x that is not the same length as y but greater than 1 item long the following is probably most sensible.