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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control significant figures with an option #72

Closed
cboettig opened this Issue Jan 4, 2018 · 8 comments

Comments

Projects
None yet
5 participants
@cboettig

cboettig commented Jan 4, 2018

For instance, I see that

Digits after the first three are dimmed to emphasise the important components.

But you'll have to explain to me how the digits 201 are the important components of the year column in the example 馃槢 . Being able to change the default behavior somehow to give me 4 digits would be nice in instances like my class where students end up reading in a lot of examples where year is a column. I want them to like tibbles and not get frustrated by this unintuitive behavior.

@hadley

This comment has been minimized.

Member

hadley commented Jan 8, 2018

The underlying problem here is #57 - I think if we fix that an option will not be necessary.

I'd prefer to push as far as we can before introducing more options, since options substantially increase the testing complexity, and make the package behave differently for different people. If this new behaviour is too annoying, we can definitely consider options, but I'd like to give it more time (i.e. open again in 6 months time if it's still a problem and I'll be more amenable)

@hadley hadley closed this Jan 8, 2018

@hadley

This comment has been minimized.

Member

hadley commented Jan 8, 2018

I've changed my mind - it's causing enough pain for enough people right now that we should have someway to suppress.

Probably easiest to parameterise as option(pillar.sigfigs = 3) allowing option(pillar.sigfigs = Inf)to turn it off.

@hadley hadley reopened this Jan 8, 2018

@hadley hadley changed the title from Consider use of `options` or similar to control styling behavior? to Control significant figures with an option Jan 8, 2018

@ilarischeinin

This comment has been minimized.

ilarischeinin commented Jan 9, 2018

Unaware of this issue, I was actually already in the middle of implementing this kind of option for my own use. But then I came here to check if there was any discussion in more general terms about the question of left-hand-sides of numbers and significant digits vs. thousands separators.

As a little background, I was surprised at first when I saw that in e.g. 1234 the three digits with a separate color are 123 and not 234. Also, I would've thought that if 123456789 was shown in two colors, 123 and 789 would be shown in one, and 456 in the other color. That is, I thought that the two colors represented thousands separators. I was therefore confused what it actually meant, and only from the documentation learned that it represented significant digits.

Since I didn't want to use it that way, I started to implement an option so I could use options(pillar.sigfigs = Inf).

But then I got to thinking that would the thousands separator idea actually be a more useful use case for the colors than significant digits? Consistency is important, but since sigfig already means different things for the rhs (colors and rounding) and lhs (no rounding, only colors), I'm not sure if that rules out the idea.

I definitely haven't looked into this very deeply, so there might be fairly obvious factors at play that make my suggestion ridiculous. Or maybe it's just plain stupid. But since I have spent a fair amount of time staring at integers on the scale of millions (base pair numbers in the human genome), I for one see a lot of potential in this kind of representation (color formatting) of thousands separators. Use of commas, or extra characters in general, is problematic for copy&paste.

Or maybe keep significant digits behaving as it is, but include a new option for the thousands separator. That one could default to not be shown, but when set, it would override the significant digits on the lhs.

I'm happy to work on this and make a PR if it's deemed useful.

@dpeterson71

This comment has been minimized.

dpeterson71 commented Jan 10, 2018

I agree that this has to change. The current implementation makes inspecting tibbles almost impossible for me. I LOVE the alignment along decimal points, but the forced highlight of only three digits is confusing at best. Not only is this unintuitive (as cboettig indicates), it is visually distracting
in many cases.

@krlmlr

This comment has been minimized.

Member

krlmlr commented Jan 10, 2018

See #78 for a suggestion for visible thousand separators using a very light gray background every other three digits.

@krlmlr krlmlr closed this in #79 Jan 11, 2018

krlmlr added a commit that referenced this issue Jan 11, 2018

Add options to control behavior (#79)
- New options to control the output, with defaults that match the current behavior unless stated otherwise:

    - `pillar.sigfig` to control the number of significant digits, for highlighting and truncation (#72),
    - `pillar.subtle` to specify if insignificant digits should be printed in gray (#72),
    - `pillar.neg` to specify if negative digits should be printed in red,
    - `pillar.bold` to specify if column headers should be printed in bold (default: `FALSE`, #76),
    - `pillar.min_title_chars` to specify the minimum number of characters to display for each column name (default: 15 characters, #75).

krlmlr added a commit that referenced this issue Jan 11, 2018

Merge tag 'v1.0.99.9000'
- `NA` values are now shown in plain red, without changing the background color (#70).
- New options to control the output, with defaults that match the current behavior unless stated otherwise:
    - `pillar.sigfig` to control the number of significant digits, for highlighting and truncation (#72),
    - `pillar.subtle` to specify if insignificant digits should be printed in gray (#72),
    - `pillar.neg` to specify if negative digits should be printed in red,
    - `pillar.bold` to specify if column headers should be printed in bold (default: `FALSE`, #76),
    - `pillar.min_title_chars` to specify the minimum number of characters to display for each column name (default: 15 characters, #75).
- Shortened abbreviations for types: complex: cplx -> cpl, function: fun -> fn, factor: fctr -> fct (#71).
- Date columns now show sub-seconds if the `digits.secs` option is set (#74).
- Work around failing CRAN tests on Windows.
@ilarischeinin

This comment has been minimized.

ilarischeinin commented Jan 11, 2018

Thank you for the new options in #79!

However, I still think there should either be

  • a separation in how significant figures are treated on the left and right hand sides,
  • a mode that didn't force the number of significant digits to be set (like with base R), or
  • a separate option that would override the formatting of lhs's (#78).

I really like having subtle for things like column headers or how POSIXct's are displayed. So, I would prefer not to turn it off. But if I don't turn it off, I'm forced to set sigfig to some value. If it's small (like 3), numbers (or their lhs's to be exact) look funny. If it's large (like 10), there are many unnecessary zeros on the rhs's (#62 is about this, but I think the functionality discussed on that issue would be a slippery slope to go down).

screen shot 2018-01-11 at 16 15 24

@hadley

This comment has been minimized.

Member

hadley commented Jan 11, 2018

That is not under consideration right now. It needs more discussion, and we need to get a release out to resolve the biggest problems.

@krlmlr

This comment has been minimized.

Member

krlmlr commented Jan 15, 2018

@ilarischeinin: Happy to discuss this in a separate issue or even pull request ;-)

krlmlr added a commit that referenced this issue Jan 19, 2018

Merge tag 'v1.1.0'
- `NA` values are now shown in plain red, without changing the background color (#70).
- New options to control the output, with defaults that match the current behavior unless stated otherwise:
    - `pillar.sigfig` to control the number of significant digits, for highlighting and truncation (#72),
    - `pillar.subtle` to specify if insignificant digits should be printed in gray (#72),
    - `pillar.neg` to specify if negative digits should be printed in red,
    - `pillar.bold` to specify if column headers should be printed in bold (default: `FALSE`, #76),
    - `pillar.min_title_chars` to specify the minimum number of characters to display for each column name (default: 15 characters, #75).
- Shortened abbreviations for types: complex: cplx -> cpl, function: fun -> fn, factor: fctr -> fct (#71).
- Date columns now show sub-seconds if the `digits.secs` option is set (#74).
- Very wide tibbles now print faster (#85).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment