title: Remove sequence of rows conditional on value in single cell in group-first position
body: <p>In this type of data:</p>
  <pre><code>df &lt;- data.frame(
    Sequ = c(1,1,2,2,2,3,3,3),
    G = c(&quot;A&quot;, &quot;B&quot;, &quot;*&quot;, &quot;B&quot;, &quot;A&quot;, &quot;A&quot;, &quot;*&quot;, &quot;B&quot;)
  )
  </code></pre>
  <p>I need to filter out rows grouped by <code>Sequ</code> <strong>iff</strong> the <code>Sequ</code>-<em>first</em> value is <strong><code>*</code></strong>. I can do it like so, but was wondering if there's a more direct and more elegant way in <strong><code>dplyr</code></strong>:</p>
  <pre><code>library(dplyr)
  df %&gt;% 
    group_by(Sequ) %&gt;%
    mutate(check = ifelse(first(G)==&quot;*&quot;, 1, 0)) %&gt;%
    filter(check != 1)
  # A tibble: 5 × 3
  # Groups:   Sequ [2]
     Sequ G     check
    &lt;dbl&gt; &lt;chr&gt; &lt;dbl&gt;
  1     1 A         0
  2     1 B         0
  3     3 A         0
  4     3 *         0
  5     3 B         0
  </code></pre>