title: Create a new column based on values from other variables
body: <p>I have data that looks like this:</p>
  
  <p>A set of 10 character variables</p>
  
  <pre><code>Char&lt;-c("A","B","C","D","E","F","G","H","I","J")
  </code></pre>
  
  <p>And a data frame that looks like this</p>
  
  <pre><code>Col1&lt;-seq(1:25)
  Col2&lt;-c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,4,4,4,4,4,5,5,5,5,5)
  DF&lt;-data.frame(Col1,Col2)
  </code></pre>
  
  <p>What I would like to do is to add a third column to the data frame, with the logic that 1=A, 2=B, 3= C and so on. So the end result would be </p>
  
  <pre><code>Col3&lt;-c("A","A","A","A","A","B","B","B","B","B","C","C","C","C","C","D","D","D","D","D","E","E","E","E","E")
  DF&lt;-data.frame(Col1,Col2,Col3)
  </code></pre>
  
  <p>For this simple example I could go with a simple substitution like this question:
  <a href="https://stackoverflow.com/questions/7658316/create-new-column-based-on-4-values-in-another-column">Create new column based on 4 values in another column</a></p>
  
  <p>But my actual data set is much bigger with a lot more variables than this simple example, so writing out the equivalents as in the above answer is not a possibility.</p>
  
  <p>So I would like to have a bit of code that can be applied to a much larger data frame. Perhaps something that looped through all the values of Col2 and matched them to the location of Char. </p>
  
  <pre><code>1=Char[1]  2=Char[2] 3=Char[3]...... for the entire length of Col2
  </code></pre>
  
  <p>Or any other way that could scale up to a long monstrous data frame</p>