title: Find matching values in different row of dataframe with group_by and str_detect
body: <p>Let's say I have a table:</p>
  <pre><code>library(tidyverse)
  df &lt;- tibble(group = c(&quot;a&quot;, &quot;a&quot;, &quot;b&quot;, &quot;b&quot;, &quot;c&quot;, &quot;c&quot;),
     code = c(&quot;foo&quot;, &quot;bar&quot;, &quot;fuz&quot;, &quot;baz&quot;, &quot;fiz&quot;, &quot;boz&quot;),
     child_code = c(&quot;bar&quot;, &quot;&quot;, &quot;baz&quot;, &quot;&quot;, &quot;biz&quot;, &quot;&quot;))
  </code></pre>
  <p>I'd like to <code>group_by</code> <code>group</code> and then search for the <code>code</code> in the <code>child_code</code>column to get something like this:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th style="text-align: center;">group</th>
  <th style="text-align: center;">code</th>
  <th style="text-align: center;">child_code</th>
  <th style="text-align: center;">code_in_child_code</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td style="text-align: center;">a</td>
  <td style="text-align: center;">foo</td>
  <td style="text-align: center;">bar</td>
  <td style="text-align: center;">FALSE</td>
  </tr>
  <tr>
  <td style="text-align: center;">a</td>
  <td style="text-align: center;">bar</td>
  <td style="text-align: center;"></td>
  <td style="text-align: center;">TRUE</td>
  </tr>
  <tr>
  <td style="text-align: center;">b</td>
  <td style="text-align: center;">fuz</td>
  <td style="text-align: center;">baz</td>
  <td style="text-align: center;">FALSE</td>
  </tr>
  <tr>
  <td style="text-align: center;">b</td>
  <td style="text-align: center;">baz</td>
  <td style="text-align: center;"></td>
  <td style="text-align: center;">TRUE</td>
  </tr>
  <tr>
  <td style="text-align: center;">c</td>
  <td style="text-align: center;">fiz</td>
  <td style="text-align: center;">biz</td>
  <td style="text-align: center;">FALSE</td>
  </tr>
  <tr>
  <td style="text-align: center;">c</td>
  <td style="text-align: center;">boz</td>
  <td style="text-align: center;"></td>
  <td style="text-align: center;">FALSE</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I've tried:</p>
  <pre><code>df %&gt;% group_by(group) %&gt;% mutate(code_in_child_code = str_detect(child_code, code))
  </code></pre>
  <p>But (I suppose obviously) that's just looking for the <code>child_code</code> in the same row's <code>code</code> column. I want to seach the <code>child_code</code> column for the any value in the whole group's codes.</p>
  <p>Any help would be much appreciated.</p>