Skip to content

Commit b08db7e

Browse files
ensure data.table retains data.frame inheritance
1 parent 8994c59 commit b08db7e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

R/print.data.table.R

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
9090
if (show.indices && !is.null(indices(x))) {
9191
classes <- c(classes, rep("<index>", length(indices(x))))
9292
}
93+
if (!inherits(toprint, "data.frame")) {
94+
class(toprint) <- c("data.table", "data.frame")
95+
}
9396
require_bit64_if_needed(x)
9497
toprint=format.data.table(toprint, na.encode=FALSE, timezone = timezone, ...) # na.encode=FALSE so that NA in character cols print as <NA>
9598

@@ -130,6 +133,7 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
130133
print_default = function(x) {
131134
if (col.names != "none") cut_colnames = identity
132135
cut_colnames(print(x, right=TRUE, quote=quote, na.print=na.print))
136+
# prints names of variables not shown in the print
133137
if (trunc.cols) trunc_cols_message(not_printed, abbs, class, col.names)
134138
}
135139
if (printdots) {

0 commit comments

Comments
 (0)