Commit d63ed217 authored by houyun's avatar houyun
Browse files

funs of converting md_tbl to normal df

parent 15d6192a
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -8,7 +8,9 @@ S3method(annotateGrob,ggplot)
S3method(annotateGrob,grob)
S3method(annotateGrob,numeric)
S3method(annotateGrob,raster)
S3method(as.data.frame,md_tbl)
S3method(as_md_tbl,corr.test)
S3method(as_tibble,md_tbl)
S3method(c,marker)
S3method(get_order,character)
S3method(get_order,dendrogram)
+18 −0
Original line number Diff line number Diff line
@@ -301,3 +301,21 @@ simplify <- function(md, keep = TRUE) {
  }
  md
}

#' @export
as.data.frame.md_tbl <- function(x, ...) {
  if (empty(x)) {
    return(as.data.frame(list()))
  }
  x <- x[names(x)]
  class(x) <- "data.frame"
  x
}

#' @importFrom tibble as_tibble
#' @export
as_tibble.md_tbl <- function(x, ...) {
  x <- as.data.frame(x)
  class(x) <- c("tbl_df", "tbl", "data.frame")
  x
}