| %vin% {validate} | R Documentation |
A membership operator like %in% that handles
NA more consistently with R's other logical comparison operators.
x %vin% table
x |
vector or |
table |
vector or |
R's basic comparison operators (almost) always return NA when one
of the operands is NA. The %in% operator is an exception.
Compare for example NA %in% NA with NA == NA.
# we cannot be sure about the first element:
c(NA, "a") %vin% c("a","b")
# we cannot be sure about the 2nd and 3rd element (but note that they
# cannot both be TRUE):
c("a","b","c") %vin% c("a",NA)
# we can be sure about all elements:
c("a","b") %in% character(0)