title: Categorizing Values in a data.frame
body: <p>I have the following sample data frame:</p>
  
  <pre><code>&gt; df &lt;- data.frame(v=c("a", "a", "b", "b", "c", "d", "d"))
  &gt; df
    v 
  1 a 
  2 a 
  3 b 
  4 b 
  5 c 
  6 d 
  7 d 
  </code></pre>
  
  <p>I would like to categorize these values in a separate column based on some arbitrary mapping.  For example:</p>
  
  <ul>
  <li>a -> x</li>
  <li>b -> x</li>
  <li>c -> y</li>
  <li>d -> y</li>
  </ul>
  
  <p>So afterwards, I would have the following:</p>
  
  <pre><code>  v cat
  1 a   x
  2 a   x
  3 b   x
  4 b   x
  5 c   y
  6 d   y
  7 d   y
  </code></pre>
  
  <p>Thank you</p>