R compare multiple values with vector and return vector [duplicate]

Just try:

 A %in% Targets

The %in% function tells you if each element of the first argument equals one of the elements of the second argument, that’s exactly what you are looking for.

Leave a Comment