Skip to content

finding numbers in a range

2 messages · Salih Tuna, David Winsemius

#
On Jun 1, 2011, at 5:07 PM, Salih Tuna wrote:

            
If this represents the full complexity of the problem then  
findInterval would work:

 > findInterval(c(0,2,25), c(1,3,6,9,15,18) ) %in% c(1,3,5)
[1] FALSE  TRUE FALSE

On the other hand if the y intervals overlap then a different method  
may be needed.

 > sapply( c(0, 2, 25) , function(x) {any( y[,1] < x & x < y[,2]) })
[1] FALSE  TRUE FALSE