@@ -63,23 +63,23 @@ print.data.table = function(x, topn=getOption("datatable.print.topn"),
6363 return (invisible (x ))
6464 }
6565 if (show.indices ) {
66- indices <- names(attr(x , " index" , exact = TRUE )) # Get actual index names
66+ indices <- names(attr(x , " index" , exact = TRUE ))
6767 if (length(indices )) {
6868 # Clean index formatting
69- cleaned_indices <- gsub(" ^__|_" , " , " , indices )
69+ cleaned_indices <- gsub(" ^__|_" , " , " , indices )
7070 cleaned_indices <- sub(" , $" , " " , cleaned_indices )
7171 # Create header string (matches key display style)
7272 header <- paste0(" Indices: " , paste(cleaned_indices , collapse = " , " ))
73-
74- # Add to existing header metadata instead of toprint
75- if (exists(" header" , envir = parent.frame(), inherits = FALSE )) {
76- assign(" header" , c(get(" header" , envir = parent.frame()), header ),
77- envir = parent.frame())
73+ # Add to existing header metadata instead of toprint
74+ if (exists(" header" , envir = parent.frame(), inherits = FALSE )) {
75+ assign(" header" , c(get(" header" , envir = parent.frame()), header ),
76+ envir = parent.frame())
77+ }
78+ }
79+ else {
80+ show.indices <- FALSE
7881 }
7982 }
80- else {
81- show.indices <- FALSE
82- }
8383 n_x = nrow(x )
8484 if ((topn * 2L + 1L )< n_x && (n_x > nrows || ! topnmiss )) {
8585 toprint = rbindlist(list (head(x , topn ), tail(x , topn )), use.names = FALSE ) # no need to match names because head and tail of same x, and #3306
0 commit comments