Skip to content

Commit 73263c3

Browse files
committed
correctedchanges
1 parent b15f235 commit 73263c3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

R/print.data.table.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,8 +265,8 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) {
265265
dt_width = function(x, nrow, class, row.names, col.names) {
266266
widths = apply(nchar(x, type='width'), 2L, max)
267267
if (class) widths = pmax(widths, 6L)
268-
names_widths = if (col.names == "none") rep(0L, ncol(x)) else sapply(colnames(x), nchar, type = "width")
269-
dt_widths = pmax(widths, names_widths)
268+
if (col.names != "none") names = sapply(colnames(x), nchar, type="width") else names = 0L
269+
dt_widths = pmax(widths, names)
270270
rownum_width = if (row.names) as.integer(ceiling(log10(nrow))+2.0) else 0L
271271
cumsum(dt_widths + 1L) + rownum_width
272272
}

inst/tests/tests.Rraw

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21142,14 +21142,14 @@ test(2314.1, any(grepl("<int>", tail(capture.output(print(dt, class = TRUE)), 2)
2114221142
# Test that class=TRUE with col.names="top" doesn't show classes at bottom
2114321143
test(2314.2, !any(grepl("<int>", tail(capture.output(print(dt, class = TRUE, col.names = "top")), 2))), TRUE)
2114421144

21145-
test(2313.1, {
21145+
test(2315.1, {
2114621146
dt <- data.table(short=1:3, verylongcolumnname=4:6)
2114721147
print(dt, col.names="none")
21148-
}, output="1: 1 4\n2: 2 5\n3: 3 6\n")
21148+
}, output="1: 1 4\n2: 2 5\n3: 3 6")
2114921149
test(2313.2, {
2115021150
dt <- data.table(x=123456, y="wide_string")
2115121151
print(dt, col.names="none")
21152-
}, output="1: 123456 wide_string\n")
21152+
}, output="1: 123456 wide_string")
2115321153
test(2313.3, {
2115421154
dt <- data.table(a=NA_integer_, b=NaN)
2115521155
print(dt, col.names="none")

0 commit comments

Comments
 (0)