title: Vectorized ifelse statements for bucketization
body: <p>I have written a function that accepts a vector of hours-of-the-day, i.e. numbers between 0 and 23, and places each hour into one of 8 contiguous buckets. For example, hours 0, 1, and 2 are placed into bucket 1, and hours 21, 22, and 23 are in bucket 8. The buckets are returned as a vector.</p>
  <p>The ifelse structure is really complex, and in the future I may increase or decrease the size of each bucket. Can someone suggest an alternative?</p>
  <pre><code>getBucket &lt;- function(hour)
  {
      ifelse (hour &lt; 3, 1, ifelse (hour &lt; 6, 2, ifelse (hour &lt; 9, 3, ifelse (hour &lt; 12, 4, ifelse (hour &lt; 15, 5, ifelse (hour &lt; 18, 6, ifelse (hour &lt; 21, 7, 8)))))))
  }
  </code></pre>