title: R: Assign values by interval using vectorisation
body: <p>Let's have a numeric vector:</p>
  
  <pre><code>a &lt;- round(runif(20, 1, 5), 0)
  [1] 3 5 4 2 1 2 3 4 5 2
  </code></pre>
  
  <p>I need to assign values to these numbers using table like this:</p>
  
  <pre><code>1 to 2: assign "A"
  3 to 4: assign "B"
  5: assign "C"
  </code></pre>
  
  <p>This is very simple sample table, but there could be many thousands of numbers and tens of intervals.</p>
  
  <p>I can do nested if structure to test every number to find the right interval. But I am looking for better, more vectorised solution. How to solve it efficiently?</p>