title: R: define value as range / interval
body: <p>I've looked around but could not find an answer that helps. I'm trying to set up a key-value table in R where the key is defined as range or interval so that I can do a look-up to find the value of any key that falls within the range / interval.
  To give a minimal example which does not work.</p>
  
  <pre><code>data.frame(key = c(range(0, 1),
                     range(1, 2)),
             value = c("A", 
                       "B"))
  </code></pre>
  
  <p>The data frame would not hold two rows but four since R is treating lower and upper interval bound as two separate values and recycle the value column to arrive at four rows. Besides this problem, I could also not find a range / interval function where I can define lower and upper bounds.</p>
  
  <p>EDIT:
  The desired output would be a table like this:</p>
  
  <pre><code>key      value    
  (0, 1)   "A"
  (1, 2)   "B"
  </code></pre>
  
  <p>So I could do something like the following query for a value a:
  table$value[where a %in% table$key]</p>