Skip to content

long column names go past width #7797

Description

@tdhock

Related to #7788 which implemented this abbreviation:

> options(width=20);data.table(x="abcdefghijklmnopqrstuvwxyz")
                   x
              <char>
1: abcdefghijklmn...

long column names can still go over width:

> options(width=20);data.table(abcdefghijklmnopqrstuvwxyz=1)
   abcdefghijklmnopqrstuvwxyz
                        <num>
1:                          1
> options(width=20, datatable.print.trunc.cols=TRUE);data.table(abcdefghijklmnopqrstuvwxyz=1)
1 variable not shown: [abcdefghijklmnopqrstuvwxyz <num>]

I would expect some output like:

> options(width=20);data.table(abcdefghijklmnopqrstuvwxyz=1)
   abcdefghijklmnop…
               <num>
1:                 1
> options(width=20, datatable.print.trunc.cols=TRUE);data.table(abcdefghijklmnopqrstuvwxyz=1)
1 variable not shown:
abcdefghijklm… <num>

in comparison, others go over width too

> options(width=20);data.frame(x="abcdefghijklmnopqrstuvwxyz")
                           x
1 abcdefghijklmnopqrstuvwxyz
> options(width=20);data.frame(abcdefghijklmnopqrstuvwxyz=1)
  abcdefghijklmnopqrstuvwxyz
1                          1
> options(width=20);tibble::tibble(abcdefghijklmnopqrstuvwxyz=1)
# A tibble: 1 × 1
# ℹ 1 more
#   variable:
#   abcdefghijklmnopqrstuvwxyz <dbl>
> options(width=80);tibble::tibble(abcdefghijklmnopqrstuvwxyz=1)
# A tibble: 1 × 1
  abcdefghijklmnopqrstuvwxyz
                       <dbl>
1                          1
> 

this is not high priority because long column names are not frequent.

Activity

  1. venom1204 commented on Jun 20, 2026

    @venom1204
    Contributor

    hi @tdhock @joshhwuu

    I looked into issue and have a proposed fix. It applies header truncation using the existing char.trunc() logic, updates empty data.table summaries and the variables not shown footer, and integrates the truncated widths into the layout calculations.

    if this sounds good i will be happy to proceed with teh pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions