From 9c8500aa4d08b329b9116e278fd48fba8a4be329 Mon Sep 17 00:00:00 2001 From: venom1204 Date: Sun, 28 Jun 2026 19:22:33 +0000 Subject: [PATCH 1/3] updaetde logic --- R/print.data.table.R | 9 ++++++++- inst/tests/tests.Rraw | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/R/print.data.table.R b/R/print.data.table.R index e602f80d6..e9baf7a78 100644 --- a/R/print.data.table.R +++ b/R/print.data.table.R @@ -131,7 +131,14 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"), trunc.cols = length(not_printed) > 0L } print_default = function(x) { - if (col.names != "none") cut_colnames = identity + if (col.names != "none") { + cut_colnames = identity + } else if (isFALSE(row.names)) { + cut_colnames = function(x) { + out = capture.output(x) + if (length(out) > 0L) writeLines(out[-1L]) + } + } cut_colnames(print(x, right=TRUE, quote=quote, na.print=na.print)) # prints names of variables not shown in the print if (trunc.cols) trunc_cols_message(not_printed, abbs, class, col.names) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 3f201f975..75fb0ec46 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21683,3 +21683,8 @@ max_ppsize = local({ x = as.data.table(as.list(1:max_ppsize)) test(2376, rbindlist(list(x)), x) rm(x, max_ppsize) + +# #7735 col.names="none" should suppress only column headers, not data +test(2377.1, print(data.table(c1=1:2, c2=letters[1:2]), nrows=Inf, class=FALSE, row.names=FALSE, show.indices=FALSE, print_keys=FALSE, col.names="none"), output=" 1 a\n 2 b") +test(2377.2, print(data.table(x=1:3), class=FALSE, row.names=FALSE, col.names="none"), output=" 1\n 2\n 3") +test(2377.3, print(data.table(c1=1:3, c2=letters[1:3]), row.names=TRUE, class=FALSE, col.names="none"), output="1: 1 a\n2: 2 b\n3: 3 c") From 8f8613a4819495db075d20df37fcb2e2a2e4c0ed Mon Sep 17 00:00:00 2001 From: venom1204 Date: Mon, 29 Jun 2026 18:19:19 +0000 Subject: [PATCH 2/3] added news --- NEWS.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS.md b/NEWS.md index daa815151..9f182939b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -60,6 +60,8 @@ 13. `rbindlist()` (and therefore the `rbind()` method for `data.table`s) no longer raises an error upon encountering more than approximately 50000 columns in a list entry, [#7793](https://github.com/Rdatatable/data.table/issues/7793). The bug was introduced in `data.table` version 1.18.2.1. Thanks to @rickhelmus for the report and @aitap for the fix. +14. `print.data.table()` now correctly displays data when `col.names="none"` and `row.names=FALSE`, [#7735](https://github.com/Rdatatable/data.table/issues/7735). Previously, the output was entirely suppressed because the internal logic relied on row markers (e.g., `1:`) to identify data lines. Thanks to @jan-swissre for the report and @YourGitHubHandle for the fix. + ### Notes 1. {data.table} now depends on R 3.5.0 (2018). From 56acefcc4d28e5e55a044c1ab1477317db4d44ef Mon Sep 17 00:00:00 2001 From: venom1204 Date: Mon, 29 Jun 2026 18:41:51 +0000 Subject: [PATCH 3/3] .. --- inst/tests/tests.Rraw | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/inst/tests/tests.Rraw b/inst/tests/tests.Rraw index 489e62453..3edb7acec 100644 --- a/inst/tests/tests.Rraw +++ b/inst/tests/tests.Rraw @@ -21777,6 +21777,6 @@ test(2377.91, truelength(dt$a), 0L) test(2377.92, {setallocrow(dt); truelength(dt$a)}, 3L) # #7735 col.names="none" should suppress only column headers, not data -test(2377.1, print(data.table(c1=1:2, c2=letters[1:2]), nrows=Inf, class=FALSE, row.names=FALSE, show.indices=FALSE, print_keys=FALSE, col.names="none"), output=" 1 a\n 2 b") -test(2377.2, print(data.table(x=1:3), class=FALSE, row.names=FALSE, col.names="none"), output=" 1\n 2\n 3") -test(2377.3, print(data.table(c1=1:3, c2=letters[1:3]), row.names=TRUE, class=FALSE, col.names="none"), output="1: 1 a\n2: 2 b\n3: 3 c") +test(2378.1, print(data.table(c1=1:2, c2=letters[1:2]), nrows=Inf, class=FALSE, row.names=FALSE, show.indices=FALSE, print_keys=FALSE, col.names="none"), output=" 1 a\n 2 b") +test(2378.2, print(data.table(x=1:3), class=FALSE, row.names=FALSE, col.names="none"), output=" 1\n 2\n 3") +test(2378.3, print(data.table(c1=1:3, c2=letters[1:3]), row.names=TRUE, class=FALSE, col.names="none"), output="1: 1 a\n2: 2 b\n3: 3 c")