how to combine the "TRUE FALSE" into "FALSE" using R?
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.
Use all():
R> all(c(1,2) %in% 1:4)
[1] TRUE
R> all(c(1,5) %in% 1:4)
[1] FALSE
精彩评论