title: Replace variable in one column differentially based on another variable
body: <p>I have a column in one db that is a variable, with a corresponding index value in another column.  I would like to replace the index variable with a different set of data, but based on the variable in the first column.</p>
  
  <pre><code>Col1 Col2 
  
  A    1
  A    2
  A    3
  A    4
  B    1
  B    2
  B    3
  B    4
  C    1
  C    2
  C    3
  C    4
  </code></pre>
  
  <p>I want to replace the 1 through 4 values with vectors dependent on the Col1 value.</p>
  
  <pre><code>If A: replace c(1:4) with c(10, 5, 2, 4)
  If B: replace c(1:4) with c(20, 19, 8, 5)
  IF C: replace c(1:4) with c(30, 25, 20, 17)
  </code></pre>
  
  <p>This is the code I've used before  to do this in a column without dependency on another, but I can't get it to work with my current situation:</p>
  
  <pre><code>col
  1
  2
  3
  4
  
  index &lt;- c(1:4)
  foo &lt;- c(4,5,6,8)
  df$col &lt;-  foo[match(df$col, index)]
  
  col
  4
  5
  6
  8
  </code></pre>