please...can you tell me how can I create a function that finds the number of identical values in three vectors? And the result should be 2. (beause 8. and 10. are same in vectors) The vectors are:
a = 1:10 b = 4:15 d = c(8, 10, 18)
I think the most efficient way is the answer by @Dason. Below is another option with mapply + rowSums
mapply
rowSums
v <- list(a,b,d) sum(rowSums(mapply(`%in%`,list(unique(unlist(v))),v))==length(v))
which gives
[1] 2
2.1m questions
2.1m answers
60 comments
57.0k users