The R %in% operator

前端 未结 1 673
后悔当初
后悔当初 2020-12-04 08:08

In R, I have am running the following script:

> 1:6 %in% 0:36
[1] TRUE TRUE TRUE TRUE TRUE TRUE

Which is clearly producing

相关标签:
1条回答
  • 2020-12-04 08:25

    You can use all

    > all(1:6 %in% 0:36)
    [1] TRUE
    > all(1:60 %in% 0:36)
    [1] FALSE
    

    On a similar note, if you want to check whether any of the elements is TRUE you can use any

    > any(1:6 %in% 0:36)
    [1] TRUE
    > any(1:60 %in% 0:36)
    [1] TRUE
    > any(50:60 %in% 0:36)
    [1] FALSE
    
    0 讨论(0)
提交回复
热议问题