Skip to content

Commit 6787c0c

Browse files
ensure data.table retains data.frame inheritance
1 parent b08db7e commit 6787c0c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

R/print.data.table.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,15 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
8585
printdots = FALSE
8686
if (show.indices) toprint = cbind(toprint, index_dt)
8787
}
88+
require_bit64_if_needed(x)
89+
if (!inherits(toprint, "data.frame")) {
90+
class(toprint) <- c("data.table", "data.frame")
91+
}
8892
classes <- classes1(toprint)
8993
col_names <- colnames(toprint)
9094
if (show.indices && !is.null(indices(x))) {
9195
classes <- c(classes, rep("<index>", length(indices(x))))
9296
}
93-
if (!inherits(toprint, "data.frame")) {
94-
class(toprint) <- c("data.table", "data.frame")
95-
}
96-
require_bit64_if_needed(x)
9797
toprint=format.data.table(toprint, na.encode=FALSE, timezone = timezone, ...) # na.encode=FALSE so that NA in character cols print as <NA>
9898

9999
# FR #353 - add row.names = logical argument to print.data.table

0 commit comments

Comments
 (0)