title: R - Cut numeric vector into bins using closed and open intervals
body: <p>Using the <code>cut()</code> function I know how to take a numeric vector and bin it according to semi-open intervals</p>
  
  <pre><code>(0, 10], (10. 19], (19, 20], (20, 26], etc...
  </code></pre>
  
  <p>or</p>
  
  <pre><code>[0, 10), [10, 19), [19, 20), [20, 26), etc....
  </code></pre>
  
  <p>How can I bin a vector with a combination of closed and open intervals, such as</p>
  
  <pre><code>(0, 10), [10, 20], (20, 29], (29, 48), [48], (48, 56), etc...?
  </code></pre>
  
  <p>Please note that I want to create a closed interval that consists of a single number.</p>
  
  <p>Is there a way to use the <code>cut()</code> function or some other function to do this? Is it time for a new function?!</p>
  
  <p><strong>EDIT</strong></p>
  
  <pre><code>boyScale &lt;- function(x) {
  ret &lt;- 
  ifelse(x &lt; 16.3,  1,
  ifelse(x = 16.3,  2,
  ifelse(x &lt; 20.8,  3,
  ifelse(x = 20.8,  4,
  ifelse(x &lt; 21.91, 5,
  ifelse(x = 21.91, 6,
  ifelse(x &lt; 28.2,  7,
  ifelse(x = 28.2,  8,
  ifelse(x &lt; 37.3,  9,
  ifelse(x = 37.3, 10, 11))))))))))
  return(ret)
  }
  </code></pre>
  
  <p>I tried this with the number 25.24, and got the following error message</p>
  
  <pre><code>Error in ifelse(x = 16.3, 2, ifelse(x &lt; 20.8, 3, ifelse(x = 20.8, 4, ifelse(x &lt; : unused argument (x = 16.3) 
  </code></pre>
  
  <p>Any ideas?</p>