title: How to find the given value from the range of values?
body: <pre><code>I have have the below data :
  
  Y          z
  100-800    a
  150-600    b
  200-300    c
  400-600    d
  4000-12000 e
  </code></pre>
  
  <p>Any help would be really appreciated.</p>
  
  <p>Based on given value of x (i.e x=100) it should find the values in the given ranges of Y and give the corresponding values of Y and z.If the given of x is not in the given ranges of Y then it should find the nearer range and give corresponding values of Y and Z.</p>
  
  <p>DT[, list(OK = 1 %in% seq(Y, Y)), by = Z]</p>
  
  <p>For given value of X=110</p>
  
  <p>output should be </p>
  
  <pre><code>Y          Z
  100-800    a
  
  For x=200
  
  Y          z
  100-800    a
  150-600    b
  200-300    c
  
  For x=12500
  
  Y             z
  4000-12000    e
  </code></pre>