What does multiple% in% in a row do?
1 answer
First of all, you perform this operation: a %in% b
as a result TRUE FALSE FALSE
. Then you are basically making a chain c(TRUE,FALSE,FALSE) %in% c
that will of course lead to everyone False
.
You can try this to get your desired vector of booleans (given position):
a == Reduce(function(u,v) ifelse(u==v, u, F), list(a,b,c))
#[1] TRUE FALSE FALSE
If you want position-independent generic elements, you can do:
Reduce(intersect, list(a,b,c))
+5
source to share