@@ -139,6 +139,8 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
139139 print_default(toprint )
140140 return (invisible (x ))
141141 }
142+ if (col.names == " none" )
143+ colnames(toprint ) <- rep.int(" " , ncol(toprint ))
142144 if (nrow(toprint )> 20L && col.names == " auto" )
143145 # repeat colnames at the bottom if over 20 rows so you don't have to scroll up to see them
144146 # option to shut this off per request of Oleg Bondar on SO, #1482
@@ -259,8 +261,8 @@ char.trunc = function(x, trunc.char = getOption("datatable.prettyprint.char")) {
259261dt_width = function (x , nrow , class , row.names , col.names ) {
260262 widths = apply(nchar(x , type = ' width' ), 2L , max )
261263 if (class ) widths = pmax(widths , 6L )
262- if (col.names != " none" ) names = sapply(colnames(x ), nchar , type = " width" ) else names = 0L
263- dt_widths = pmax(widths , names )
264+ names_widths = if (col.names == " none" ) rep( 0L , ncol( x )) else sapply(colnames(x ), nchar , type = " width" )
265+ dt_widths = pmax(widths , names_widths )
264266 rownum_width = if (row.names ) as.integer(ceiling(log10(nrow ))+ 2.0 ) else 0L
265267 cumsum(dt_widths + 1L ) + rownum_width
266268}
@@ -292,4 +294,4 @@ trunc_cols_message = function(not_printed, abbs, class, col.names){
292294knit_print.data.table = function (x , ... ) {
293295 if (! shouldPrint(x )) return (invisible (x ))
294296 NextMethod()
295- }
297+ }
0 commit comments