title: R partial match in data frame
body: <p>How can I address a partial match in a data frame?
  Lets say this is my df
   df</p>
  
  <pre><code>   V1  V2  V3 V4
  1 ABC 1.2 4.3  A
  2 CFS 2.3 1.7  A
  3 dgf 1.3 4.4  A
  </code></pre>
  
  <p>and I want to add a column V5 containing a number 111 only if the value in V1 contains a "f" in the name and a number 222 only if the value in V1 contains a "gf". Will I get problems since several values contain an "f" - or does the order I ender the commands will take care of it?</p>
  
  <p>I tried something like:</p>
  
  <pre><code>df$V5&lt;- ifelse(df$V1 = c("*f","*gf"),c=(111,222) )
  </code></pre>
  
  <p>but it does not work.</p>
  
  <p>Main problem is how can I tell R to look for "partial match"?</p>
  
  <p>Thanks a million for your help!</p>