title: How to Filter out Rows per Group after Condition Occurrs
body: <p>I am new to R programming and attempting to remove certain rows per a group of rows after a filtering criteria has been met. </p>
  
  <p>Scenario: For each GROUP, if 2 TYPE "B" are in a row, remove all the following rows for that GROUP. The "Include in DataSet" column shows what the output should be.</p>
  
  <p>Here is my example input:</p>
  
  <pre><code>GROUP   TYPE    Include in DataSet?
  --------------------------------------------
  1       A       yes
  1       A       yes
  1       B       yes
  1       B       yes
  1       B       no
  2       A       yes
  2       B       yes
  2       B       yes
  2       A       no
  2       B       no
  2       B       no
  
  DF = structure(list(GROUP = c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 
  2L, 2L), TYPE = c("A", "A", "B", "B", "B", "A", "B", "B", "A", 
  "B", "B"), inc = c("yes", "yes", "yes", "yes", "no", "yes", "yes", 
  "yes", "no", "no", "no")), .Names = c("GROUP", "TYPE", "inc"), row.names = c(NA, 
  -11L), class = "data.frame")
  </code></pre>
  
  <p>Expected Output:</p>
  
  <pre><code>GROUP   TYPE    Include in DataSet?
  --------------------------------------------
  1       A       yes
  1       A       yes
  1       B       yes
  1       B       yes
  2       A       yes
  2       B       yes
  2       B       yes
  </code></pre>
  
  <p>I have tried writing some code, with no luck due to grouping issue.</p>
  
  <pre><code>i=1
  j=2
  x &lt;- allrows
  for (i in x){
    for(j in x){
      if(i==j){
        a$REMOVE=1
      }
      else{
        a$REMOVE=2
      }
    }
  }
  </code></pre>