title: Extending tibble: getting the new S3 class to stick
body: <p>For <a href="https://github.com/ropensci/drake/issues/489" rel="nofollow noreferrer">ropensci/drake#489</a>, I would like to define a new print method for <code>tibbles</code> of class <code>"drake_plan"</code>. I read the <a href="https://cran.r-project.org/web/packages/tibble/vignettes/extending.html" rel="nofollow noreferrer">guide on extending <code>tibble</code></a>, which was helpful for some of the requirements. But the new <code>"drake_plan"</code> S3 class drops during <code>dplyr</code> operations.</p>
  
  <pre><code>#' @title Mark a data frame as a `drake` workflow plan
  #' @description Used for pretty printing only (coming soon).
  #'   You do not actually have to mark plans as such.
  #'   You can keep them as ordinary data frames.
  #' @export
  #' @keywords internal
  #' @param x object to mark as a `drake` plan
  #' @param ... other arguments to the method
  #' @examples
  #' plan &lt;- list(target = "x", command = "get_data()")
  #' class(plan)
  #' plan &lt;- as_drake_plan(plan)
  #' class(plan)
  as_drake_plan &lt;- function(x){
    UseMethod("as_drake_plan")
  }
  
  as_drake_plan_ &lt;- function(x, ...){
    tibble::new_tibble(x, ..., subclass = "drake_plan")
  }
  
  #' @export
  `[.drake_plan` &lt;- function(...){
    as_drake_plan_(NextMethod())
  }
  
  #' @export
  #' @rdname as_drake_plan
  as_drake_plan.data.frame &lt;- as_drake_plan_
  
  #' @export
  #' @rdname as_drake_plan
  as_drake_plan.list &lt;- as_drake_plan_
  
  #' @export
  #' @rdname as_drake_plan
  as_drake_plan.tbl_df &lt;- as_drake_plan_
  
  library(dplyr)
  library(drake)
  plan &lt;- drake_plan(
    x = get_data(),
    y = analyze_data(x)
  ) %&gt;%
    as_drake_plan() %&gt;%
    print
  #&gt; # A tibble: 2 x 2
  #&gt;   target command        
  #&gt; * &lt;chr&gt;  &lt;chr&gt;          
  #&gt; 1 x      get_data()     
  #&gt; 2 y      analyze_data(x)
  class(plan)
  #&gt; [1] "drake_plan" "tbl_df"     "tbl"        "data.frame"
  filter(plan, target == "x") %&gt;%
    class()
  #&gt; [1] "tbl_df"     "tbl"        "data.frame"
  </code></pre>
  
  <p>And besides <code>dplyr</code> functions, are there other situations that remove subclasses from <code>tibble</code>s?</p>