Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Greedy printing? #89

Closed
jennybc opened this issue Jun 7, 2016 · 9 comments · Fixed by #294
Closed

Greedy printing? #89

jennybc opened this issue Jun 7, 2016 · 9 comments · Fixed by #294

Comments

@jennybc
Copy link
Member

jennybc commented Jun 7, 2016

I run into this fairly often: a character vector that has some long entries and makes the printed tbl_df very disappointing. Since it can't be printed in its entirety, nothing gets printed at all and leads to a huge amount of sad whitespace.

Could printing just use all the available horizontal space and truncate the last variable? I realize it's hard to say whether the first part or the last part is more interesting to reveal. And that this feature is probably a pain in the rear to implement.

## the type variable is completely left out :(
xlsx_read_workbook_rels(ek_path)
#> Source: local data frame [3 x 3]
#> 
#>                     target                id
#>                      <chr>             <chr>
#> 1    /xl/sharedStrings.xml Rfd88d28f71e84f97
#> 2           /xl/styles.xml Ra71ceb88d7f8404d
#> 3 /xl/worksheets/sheet.xml R6082ddd3e995440f
#> Variables not shown: type <chr>.

print(xlsx_read_workbook_rels(ek_path), width = 300)
#> Source: local data frame [3 x 3]
#> 
#>                     target                id
#>                      <chr>             <chr>
#> 1    /xl/sharedStrings.xml Rfd88d28f71e84f97
#> 2           /xl/styles.xml Ra71ceb88d7f8404d
#> 3 /xl/worksheets/sheet.xml R6082ddd3e995440f
#>                                                                                type
#>                                                                               <chr>
#> 1 http://schemas.openxmlformats.org/officeDocument/2006/relationships/sharedStrings
#> 2        http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles
#> 3     http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet

## would be nice
xlsx_read_workbook_rels(ek_path)
#>                     target                id                   type
#> 1    /xl/sharedStrings.xml Rfd88d28f71e84f97 ...ships/sharedStrings
#> 2           /xl/styles.xml Ra71ceb88d7f8404d ...elationships/styles
#> 3 /xl/worksheets/sheet.xml R6082ddd3e995440f ...tionships/worksheet
@krlmlr
Copy link
Member

krlmlr commented Jun 7, 2016

Why only the last column? We could look at evenly chopping space off each column by e.g. reducing precision or truncating. See #51 for pending formatting updates.

@jennybc
Copy link
Member Author

jennybc commented Jun 7, 2016

That had crossed my mind, but I thought it would be a nonstarter. It is interesting.

But also this: I usually put specific identifying variables up front and I would hate to have less information displayed for those in order to fit in truncated versions of other variables I am less interested in.

I could go either way. It just feels like the big swath of whitespace is a lost opportunity to print something about the variables that don't completely fit.

@krlmlr
Copy link
Member

krlmlr commented Jun 8, 2016

Extra whitespace is also often caused by column names that are too long. Maybe truncate them to the length of the column, and show the full name below if necessary?

We could keep the full width for the first 2 or 3 or so columns. Anyway, I guess showing a part of the last column is not that difficult, we could start with that.

@jennybc
Copy link
Member Author

jennybc commented Jun 8, 2016

Yes, it feels like column names should never be allowed to hog horizontal space and force other variables off the edge. Truncating them to the width required by their data seems sensible.

@krlmlr
Copy link
Member

krlmlr commented Jun 8, 2016

  • add ... in the middle of the string
  • general threshold for string columns: 15 or so
  • column names are truncated if total width is too large

@hadley
Copy link
Member

hadley commented Jun 13, 2016

Related, I wonder if tibble should print with a smaller number of digits that getOption("digits") - the default of 7 is really too high, and IMO 3 or 4 would be much better. This is somewhat tangled up with #30 as digits doesn't really control the number of significant digits.

@jankatins
Copy link

I'Ve added a first implementation of the "shorter string" idea in #104

@krlmlr
Copy link
Member

krlmlr commented Aug 25, 2017

We've implemented adaptive widths in colformat, which is used as of now. Can you please try, and report any problems to the colformat repo?

@github-actions
Copy link
Contributor

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants