title: Testing whether a value matches a list of values
body: <p>This seems really obvious, but I can't find the answer anywhere.</p>
  
  <p>I have a two columns (Col1, Col2). I want to check each row of Col1 for a match with a few keywords and if I find a match, write something into Col2. I'm doing it like this:</p>
  
  <pre><code>df$Col2[df$Col1=="Bob"]&lt;-"Boy's name"
  </code></pre>
  
  <p>The problem I have is that I have lots of different names to check, so I'm ending up with a huge statement along the lines of:</p>
  
  <pre><code>df$Col2[df$Col1=="Bob" | df$Col1=="Tom" | df$Col1=="Dick" | df$Col1=="Harry"]&lt;-"Boy's name"
  </code></pre>
  
  <p>I'd prefer to do this:</p>
  
  <pre><code>df$Col2[df$Col1=="Bob|Tom|Dick|Harry"]&lt;-"Boy's name"
  </code></pre>
  
  <p>The above statement runs without an error, but it doesn't work either: it doesn't write anything to COl2. I'm guessing that it's not correctly evaluating the "Bob|Tom|Dick|Harry" bit. What am I'm doing wrong?</p>