How to write OR condition inside which in R

后端 未结 2 483
不思量自难忘°
不思量自难忘° 2021-01-26 10:04

I am unable to figure out how can i write or condition inside which in R. This statemnet does not work.

   which(value>100 |          


        
2条回答
  •  佛祖请我去吃肉
    2021-01-26 10:27

    Every value is either larger than 100 or smaller-or-equal to 200. Maybe you need other numbers or & instead of |? Otherwise, there is no problem with that statement, the syntax is correct:

    > value <- c(110, 2, 3, 4, 120)
    > which(value>100 | value<=200)
    [1] 1 2 3 4 5
    > which(value>100 | value<=2)
    [1] 1 2 5
    > which(value>100 & value<=200)
    [1] 1 5 
    

提交回复
热议问题