title: Drop factor levels once a category is reached in longitudinal data
body: <p>I have a data frame of recorded data that a longitudinal structure as this:</p>
  
  <pre><code> id          event
  1   1   registration
  2   1     inspection
  3   1     inspection
  4   1 deregistration
  5   2   registration
  6   2     inspection
  7   2 deregistration
  8   2     inspection
  9   3   registration
  10  3 deregistration
  11  3     inspection
  12  3     inspection
  13  4   registration
  14  4     inspection
  15  4     inspection
  16  4 deregistration
  </code></pre>
  
  <p>I need to drop the levels that are after one category. Essentially I need to drop the subsequent levels of <code>event</code> that are after the category <code>deregistration</code>. The data frame should look like this:</p>
  
  <pre><code>   id          event
  1   1   registration
  2   1     inspection
  3   1     inspection
  4   1 deregistration
  5   2   registration
  6   2     inspection
  7   2 deregistration
  8   3   registration
  9   3 deregistration
  10  4   registration
  11  4     inspection
  12  4     inspection
  13  4 deregistration 
  </code></pre>
  
  <p>This is de code cor generating <code>df</code></p>
  
  <pre><code>df = data.frame(id = rep(1:4, each = 4), 
                    event = as.factor(c("registration", "inspection", "inspection", "deregistration",
                                    "registration", "inspection", "deregistration", "inspection",
                                    "registration", "deregistration","inspection", "inspection",
                                    "registration", "inspection", "inspection", "deregistration")))
  </code></pre>