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

Incorrect superscript formatting for scientific notation #90

Closed
dpeterson71 opened this Issue Jan 15, 2018 · 6 comments

Comments

Projects
5 participants
@dpeterson71

dpeterson71 commented Jan 15, 2018

The pretty-printing of superscripts is not correct for numbers printed in scientific notation. For example, the number 1.23E4 is printed as 1.23e^4 which reads as 1.23 * e^4. It really should be 1.23 x 10^4, (which actually occupies more characters than the default print method) but at the very least the "e" should be "E" so as not to be confused with the natural exponent.

@krlmlr

This comment has been minimized.

Member

krlmlr commented Jan 16, 2018

I'd argue that the lower-case e is easier to distinguish from numbers. R (and many other computing environments) are doing the same, albeit without superscript:

1e10
#> [1] 1e+10

Created on 2018-01-16 by the reprex package (v0.1.1.9000).

@dpeterson71

This comment has been minimized.

dpeterson71 commented Jan 17, 2018

There are at least two features of the R output that make it clear what is happening:

  1. There is no superscript so there is no confusion about the meaning.
  2. The sign immediately follows the "e" and is connected to the power whether it is positive or negative.

Another feature of base R is that it always provides at least two digits.
For comparing magnitudes of numbers it is very easy to scan a column of three characters seeing "+" or "-" signs and a number denoting magnitude.

@jonasfoe

This comment has been minimized.

jonasfoe commented Jan 18, 2018

For me the display in the Rstudio console is very awkward with when superscript is involved.
It's kind of hard to read.
I use the menlo font on my mac which should be pretty standard.

screen shot 2018-01-18 at 15 22 51

@pqmatagi

This comment has been minimized.

pqmatagi commented Feb 2, 2018

I'm using the RStudio Server web client (Chrome, Mac, tibble 1.4.2) with the default UI scheme.

In addition to the annoying spacing as above that results from superscripting in the fixed width font, I get double superscripting in two-digit exponents - see attached screen clip.

tibble

So (IMHO) we get decreased readability compared to the lowest common denominator R formatting, with no saving in screen real estate, and no way to configure formatting consistent with the rest of the numbers printed in the console.

Please record one more vote for a backward compatibility option!

@alistaire47

This comment has been minimized.

alistaire47 commented Feb 5, 2018

This printing does make it easier to understand what those numbers are, but at small font sizes or for people with bad eyesight, they're really hard to read. An option to turn them off would be nice.

@krlmlr krlmlr added this to To Do in krlmlr Feb 7, 2018

@krlmlr krlmlr closed this in c09586b Feb 22, 2018

krlmlr automation moved this from To Do to Done Feb 22, 2018

@krlmlr

This comment has been minimized.

Member

krlmlr commented Feb 22, 2018

Thanks for your feedback, using regular digits again.

krlmlr added a commit that referenced this issue Feb 24, 2018

Merge tag 'v1.1.0.9001'
- The negation sign is printed next to the number again (#91).
- Scientific notation uses regular digits again for exponents (#90).
- Numeric values with a `"class"` attribute are now formatted using `format()` if the `pillar_shaft()` method is not implemented for that class (#88).
- Groups of three digits are now underlined, starting with the fourth before/after the decimal point (#78).

krlmlr added a commit that referenced this issue Feb 26, 2018

Merge tag 'v1.2.0'
Display
-------

- Turned off using subtle style for digits that are considered insignificant.  Set the new option `pillar.subtle_num` to `TRUE` to turn it on again (default: `FALSE`).
- The negation sign is printed next to the number again (#91).
- Scientific notation uses regular digits again for exponents (#90).
- Groups of three digits are now underlined, starting with the fourth before/after the decimal point. This gives a better idea of the order of magnitude of the numbers (#78).
- Logical columns are displayed as `TRUE` and `FALSE` again (#95).
- The decimal dot is now always printed for numbers of type `numeric`. Trailing zeros are not displayed anymore if all displayed numbers are whole numbers (#62).
- Decimal values longer than 13 characters always print in scientific notation.

Bug fixes
---------

- Numeric values with a `"class"` attribute (e.g., `Duration` from lubridate) are now formatted using `format()` if the `pillar_shaft()` method is not implemented for that class (#88).
- Very small numbers (like `1e-310`) are now printed corectly (tidyverse/tibble#377).
- Fix representation of right-hand side for `getOption(pillar.sigfig) >= 6` (tidyverse/tibble#380).
- Fix computation of significant figures for numbers with absolute value >= 1 (#98).

New functions
-------------

- New styling helper `style_subtle_num()`, formatting depends on the `pillar.subtle_num` option.

krlmlr added a commit that referenced this issue Feb 27, 2018

Merge tag 'v1.2.1'
Display
-------

- Turned off using subtle style for digits that are considered insignificant.  Negative numbers are shown all red.  Set the new option `pillar.subtle_num` to `TRUE` to turn it on again (default: `FALSE`).
- The negation sign is printed next to the number again (#91).
- Scientific notation uses regular digits again for exponents (#90).
- Groups of three digits are now underlined, starting with the fourth before/after the decimal point. This gives a better idea of the order of magnitude of the numbers (#78).
- Logical columns are displayed as `TRUE` and `FALSE` again (#95).
- The decimal dot is now always printed for numbers of type `numeric`. Trailing zeros are not shown anymore if all displayed numbers are whole numbers (#62).
- Decimal values longer than 13 characters always print in scientific notation.

Bug fixes
---------

- Numeric values with a `"class"` attribute (e.g., `Duration` from lubridate) are now formatted using `format()` if the `pillar_shaft()` method is not implemented for that class (#88).
- Very small numbers (like `1e-310`) are now printed corectly (tidyverse/tibble#377).
- Fix representation of right-hand side for `getOption("pillar.sigfig") >= 6` (tidyverse/tibble#380).
- Fix computation of significant figures for numbers with absolute value >= 1 (#98).

New functions
-------------

- New styling helper `style_subtle_num()`, formatting depends on the `pillar.subtle_num` option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment