title: Create category based on range in R
body: <p>I would like to add a column to my dataframe that contains categorical data based on numbers in another column.  I found a similar question at <a href="https://stackoverflow.com/questions/2647639/create-categorical-variable-in-r-based-on-range">Create categorical variable in R based on range</a>, but the solution provided there didn't provide the solution that I need. Basically, I need a result like this:</p>
  
  <pre><code>x   group
  3   0-5
  4   0-5
  6   6-10
  12  &gt; 10
  </code></pre>
  
  <p>The solutions suggested using <code>cut()</code> and <code>shingle()</code>, and while those are useful for dividing the data based on ranges, they do not create the new categorical column that I need.</p>
  
  <p>I have also tried using something like (please don't laugh)</p>
  
  <pre><code>data$group &lt;- "0-5"==data[data$x&gt;0 &amp; data$x&lt;5, ]
  </code></pre>
  
  <p>but that of course didn't work.  Does anyone know how I might do this correctly?</p>