Last active
April 24, 2022 12:59
-
-
Save krlmlr/35f56d625ea56ff098f965d7c6d5a382 to your computer and use it in GitHub Desktop.
Use tibble's print method for data.table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
penguins_dt <- data.table::as.data.table(palmerpenguins::penguins[1:3,]) | |
penguins_dt | |
print_data_table <- function(x, ...) { | |
# Adapted from data.table:::as.data.frame.data.table() | |
ans <- x | |
attr(ans, "row.names") <- .set_row_names(nrow(x)) | |
attr(ans, "class") <- c("tbl", "data.frame") | |
attr(ans, "sorted") <- NULL | |
attr(ans, ".internal.selfref") <- NULL | |
print(ans) | |
invisible(x) | |
} | |
assignInNamespace("print.data.table", print_data_table, asNamespace("data.table")) | |
penguins_dt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment