title: Add column with values based on grep from another column - R
body: <p>I have a data frame with this kind of information:</p>
  
  <pre><code>ID    DESCRIPTION   
  1     aaabccdd       
  2     abcdFOOsajd    
  3     1243abcsd      
  4     abc123FOO      
  </code></pre>
  
  <p>I want to add a third column which is going to receive the value 1 if the description has <code>"*FOO*"</code> on it, to get something like this:</p>
  
  <pre><code>ID    DESCRIPTION    TARGET
  1     aaabccdd       0
  2     abcdFOOsajd    1
  3     1243abcsd      0
  4     abc123FOO      1
  </code></pre>
  
  <p>I tried:</p>
  
  <pre><code>df$TARGET &lt;- ifelse(df$DESCRIPTION == grep("FOO", df$DESCRIPTION), "1", "0")
  
  Error in `==.default`(df$DESCRIPTION, grep("FOO", df$DESCRIPTION)) :
    longer object length is not a multiple of shorter object length
  </code></pre>
  
  <p>And also:</p>
  
  <pre><code>df$TARGET &lt;- ifelse(grep("FOO", df$DESCRIPTION)==TRUE, "1", "0")
  
  Error in `$&lt;-.data.frame`(`*tmp*`, "TARGET", value = c("0", "0", "0",  : 
    replacement has 826768 rows, data has 34035650
  </code></pre>
  
  <p>Any help on this? I saw other questions about this on SO, but they where on the situation when the if statement is just checking if it's perfectly equal something or a number greater than the other.</p>