| 1 |
knit_print.data.frame <- function(x, ...) { |
| 2 |
context <- render_context() |
| 3 |
|
| 4 |
# printing of certain expressions producing |
| 5 |
# 'data.table' objects should be suppressed |
| 6 |
printable <- TRUE |
| 7 |
if ("data.table" %in% loadedNamespaces() && |
| 8 |
exists("shouldPrint", envir = asNamespace("data.table"))) |
| 9 |
{ |
| 10 |
shouldPrint <- get("shouldPrint", envir = asNamespace("data.table")) |
| 11 |
printable <- tryCatch( |
| 12 |
shouldPrint(x) || !inherits(x, "data.table"), |
| 13 |
error = function(e) TRUE |
| 14 |
) |
| 15 |
} |
| 16 |
|
| 17 |
if (!printable) |
| 18 |
return(invisible(NULL)) |
| 19 |
|
| 20 |
if (!is.null(context$df_print)) { |
| 21 |
if (identical(context$df_print, knitr::kable)) { |
| 22 |
res <- c('', knitr::kable(x), '') |
| 23 |
if (knitr::is_html_output()) |
| 24 |
res <- c('<div class="kable-table">', res, '</div>') |
| 25 |
knitr::asis_output(one_string(res)) |
| 26 |
} else { |
| 27 |
context$df_print(x) |
| 28 |
} |
| 29 |
} else { |
| 30 |
print(x) |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
#' @export |
| 35 |
#' @importFrom knitr knit_print |
| 36 |
knit_print.tbl_sql <- knit_print.data.frame |
| 37 |
|
| 38 |
#' @export |
| 39 |
knit_print.grouped_df <- knit_print.data.frame |
| 40 |
|
| 41 |
#' @export |
| 42 |
knit_print.rowwise_df <- knit_print.data.frame |
| 43 |
|