title: Add specific value to a data.frame column by matching a pattern
body: <p>I have two data.frames:</p>
  
  <pre><code>pattern &lt;- data.frame(pattern = c("A", "B", "C", "D"), val = c(1, 1, 2, 2))
  
  match &lt;- data.frame(match = c("A", "C"))
  </code></pre>
  
  <p>I want to add to my data.frame pattern another column called new_val and assign "X" to each row where the value for column pattern is in the data.frame match otherwise assign "Y"</p>
  
  <pre><code>is.element(pattern$pattern, match$match)
  </code></pre>
  
  <p>[1]  TRUE FALSE  TRUE FALSE</p>
  
  <p>So, the resulting data.frame should look like:</p>
  
  <pre><code>    pattern val new_val
  1   A       1   X
  2   B       1   Y
  3   C       2   X
  4   D       2   Y
  </code></pre>
  
  <p>I achieved to do it with an ugly for-loop but I am sure this can be pretty much done in a one line R command using fancy stuff :-)</p>
  
  <p>Is anyone able to help?</p>
  
  <p>Many thanks!</p>