Skip to content
Prev 312589 / 398506 Next

screen if a value is within range

On Dec 1, 2012, at 9:55 AM, R. Michael Weylandt wrote:

            
Could just use the findInterval function:

findInterval(x, c(15,20) ) == 1

findInterval returns a numeric vector indicating which bin(s) the  
argument vector element(s) fall(s) into. Items below the lower bound  
get a zero which means if the result is used as an index the there  
will be no item chosen for that value. Items above the maximal  
boundary get a value of n+1 where n is the number of bins. (Very  
useful function.)