开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜