title: Replacing values in a column of a data.frame with values from another data.frame
body: <p>My situation is that I have a data frame with a column filled with the integers 1 to 6. I would like to replace these integers with more descriptive labels, provided in another data frame which acts as a "key":</p>
  
  <pre><code>  V1                 V2
  1  1             LABEL1
  2  2             LABEL2
  3  3             LABEL3
  4  4             LABEL4
  5  5             LABEL5
  6  6             LABEL6
  </code></pre>
  
  <p>So whenever I find a number 1 in the first data frame column (df$colX), I want to replace it with LABEL1 (i.e., label column 2, where df$colX == label column 1).</p>
  
  <p>I have tried
      <code>replace(df$colX,labels[,1],labels[,2])</code>
  but this just turns the integers into quoted integers for some reason.</p>
  
  <p>I could do this with a for loop, but that seems very slow.</p>
  
  <p>I have also followed some advice on StackOverflow about factors, but none of the columns I'm working with here seem to involve factors (read with stringsAsFactors = FALSE). Any ideas?</p>