title: R, find character string from vector, create new TRUE/FALSE columns
body: <p>I have a data frame like this:</p>
  <pre><code>df&lt;-structure(list(MRN = c(&quot;53634&quot;, &quot;65708&quot;, &quot;72122&quot;, &quot;40458&quot;, &quot;03935&quot;, 
  &quot;67473&quot;, &quot;20281&quot;, &quot;52479&quot;, &quot;10261&quot;, &quot;40945&quot;, &quot;40630&quot;, &quot;92295&quot;, 
  &quot;43505&quot;, &quot;80719&quot;, &quot;39492&quot;, &quot;44720&quot;, &quot;70691&quot;, &quot;21351&quot;, &quot;03457&quot;, 
  &quot;02182&quot;), Outcome_Diagnosis_1 = c(NA, NA, NA, &quot;Seroma of breast [N64.89]&quot;, 
  &quot;Breast implant capsular contracture [T85.44XA]; Breast implant capsular contracture [T85.44XA]; Breast implant capsular contracture [T85.44XA]&quot;, 
  NA, NA, NA, &quot;Acquired breast deformity [N64.89]&quot;, NA, NA, NA, 
  NA, &quot;Acquired breast deformity [N64.89]&quot;, NA, NA, NA, NA, NA, 
  NA), Outcome_Diagnosis_2 = c(NA, NA, NA, &quot;Extrusion of breast implant, initial encounter [T85.49XA]; Extrusion of breast implant, initial encounter [T85.49XA]; Extrusion of breast implant, initial encounter [T85.49XA]&quot;, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, &quot;Capsular contracture of breast implant, subsequent encounter [T85.44XD]; Capsular contracture of breast implant, subsequent encounter [T85.44XD]; Capsular contracture of breast implant, subsequent encounter [T85.44XD]&quot;, 
  NA, NA, NA, NA, NA, NA), Outcome_Diagnosis_3 = c(NA, NA, NA, 
  NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, &quot;Acquired breast deformity [N64.89]; Capsular contracture of breast implant, initial encounter [T85.44XA]; Capsular contracture of breast implant, initial encounter [T85.44XA]; Capsular contracture of breast implant, initial encounter [T85.44XA]&quot;, 
  NA, NA, NA, NA, NA, NA)), row.names = c(NA, -20L), class = c(&quot;tbl_df&quot;, 
  &quot;tbl&quot;, &quot;data.frame&quot;))
  </code></pre>
  <p>And I have a few vectors like this:</p>
  <pre><code>Infection&lt;-c(&quot;L76&quot;,&quot;L00&quot;, &quot;L01&quot;,&quot;L02&quot;,&quot;L03&quot;,&quot;L04&quot;, &quot;L05&quot;,&quot;L08&quot;)
  Hematoma&lt;-c(&quot;N64.89&quot;,&quot;M79.81&quot;)
  Seroma&lt;- c(&quot;L76.34&quot;)
  Necrosis&lt;- c(&quot;N64.1&quot;,&quot;T86.821&quot;)
  CapsularContracture&lt;- c(&quot;T85.44&quot;)
  MechanicalComplications&lt;- c(&quot;T85&quot;, &quot;T85.4&quot;, &quot;T85.41&quot;, &quot;T85.42&quot;, &quot;T85.43&quot;, &quot;T85.49&quot;)
  </code></pre>
  <p>What I'd like to do is create new columns in the data frame that are <code>TRUE</code>/<code>FALSE</code> for if that vector was found in each row.  (And it would just be TRUE even if it shows up multiple times in that row, i.e. it doesn't need to &quot;count&quot; them).</p>
  <p>So the output I want would be something like this:
  <a href="https://i.stack.imgur.com/5DaQi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5DaQi.png" alt="enter image description here" /></a></p>
  <p>The reason I am struggling and came to stack for help is I don't really know how to combine searching for particular strings (that might be within a longer sentence in that column) and looking over multiple columns.</p>
  <p><strong>Additional Info that might be important:</strong></p>
  <ul>
  <li>There are more columns than just those 3 outcome diagnoses, it'd be useful if the answer looked through the entire row regardless of how many columns</li>
  <li>Sometimes those codes aren't specific enough and it'd probably be useful to look for the actual words like &quot;Seroma&quot;.  I imagine that'd just be a case of swapping out the characters inside the quotes right?</li>
  </ul>