Reputation: 24665
I am using %in%
to see if the vector contain what I need, like below:
> c(1,2)%in%1:4
[1] TRUE TRUE
> c(1,5)%in%1:4
[1] TRUE FALSE
For the first case, I want the final outcome to be a single TRUE
and for the second case, the outcome needs to be a single FALSE
(i.e. like a AND truth table).
How can it be done?
Thanks.
Upvotes: 2
Views: 2144
Reputation: 8313
Use all():
R> all(c(1,2) %in% 1:4)
[1] TRUE
R> all(c(1,5) %in% 1:4)
[1] FALSE
Upvotes: 8