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

Weird problem on printed tibble when changing sig.figs #380

Closed
lbusett opened this issue Jan 31, 2018 · 3 comments
Closed

Weird problem on printed tibble when changing sig.figs #380

lbusett opened this issue Jan 31, 2018 · 3 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@lbusett
Copy link

lbusett commented Jan 31, 2018

Hi,

increasing options(pillar.sigfig) seems to break numeric representation when printing the object.

Reprex:

library(tibble)

# OK (though in my opinion trailing zeroes should not be added)
options(pillar.sigfig = 3)
tibble(val = c(0.01))
#> # A tibble: 1 x 1
#>      val
#>    <dbl>
#> 1 0.0100

# Still OK
options(pillar.sigfig = 5)
tibble(val = c(0.01))
#> # A tibble: 1 x 1
#>        val
#>      <dbl>
#> 1 0.010000

# Not ok...
options(pillar.sigfig = 6)
tibble(val = c(0.01))
#> # A tibble: 1 x 1
#>         val
#>       <dbl>
#> 1 0.001e+05

This appears to be related to some bug in pillar_shaft:

library(pillar)
# not ok...
pillar_shaft(0.010, sigfig = 6)
#> 0.001e+05

#not ok...
pillar_shaft(100.010, sigfig = 11)
#> 100.001e+05

(Working on R 3.4.1, tibble 1.4.2)

@krlmlr krlmlr added the bug an unexpected problem or unintended behavior label Feb 7, 2018
@krlmlr
Copy link
Member

krlmlr commented Feb 7, 2018

Thanks, confirmed.

@krlmlr
Copy link
Member

krlmlr commented Feb 9, 2018

Should be better now in the dev version of pillar.

@krlmlr krlmlr reopened this Feb 9, 2018
@krlmlr krlmlr closed this as completed Feb 9, 2018
krlmlr added a commit to r-lib/pillar that referenced this issue Feb 9, 2018
- New styling helper `style_subtle_num()`.
- Very small numbers (like `1e-310`) are now printe corectly (tidyverse/tibble#377).
- Fix representation of right-hand side for `getOption(pillar.sigfig) >= 6` (tidyverse/tibble#380).
- 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.
- The new option `pillar.subtle_num` (default: `FALSE`) decides if numbers use subtle highlighting for digits that are considered insignificant.
- For decimal numbers, every third digit is underlined. This gives a better idea of the order of magnitude of the numbers. The first and last digit is never underlined.
- Decimal values longer than 13 characters always print in
  scientific notation.
- Fix computation of significant figures for numbers with absolute value >= 1 (#98).
- Logical columns are displayed as `TRUE` and `FALSE` again (#95).
krlmlr added a commit to r-lib/pillar that referenced this issue Feb 26, 2018
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 to r-lib/pillar that referenced this issue Feb 27, 2018
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.
clrpackages pushed a commit to clearlinux-pkgs/R-pillar that referenced this issue Apr 11, 2018
…1.2.1

Hadley Wickham (1):
      Merge pull request #69 from wibeasley/patch-1

Kirill Müller (94):
      Merge tag 'v1.0.1'
      add codecov badge, closes #77
      document
      bump version
      use %OS for printing time (#81)
      complex -> cpl, function -> fn (#80)
      Add options to control behavior (#79)
      add CNAME
      use red color for NA, closes #70
      update output
      bump version to 1.0.99.9000
      NEWS
      up pkgdown
      fix reference index
      Merge branch 'r-1.0.99.9000' into production
      Merge tag 'v1.0.99.9000'
      add revdep results
      ignore revdep dir
      add check file
      only one level
      up results
      update revdep results
      commit and push after run
      apply type style for each pillar again
      bump testthat dep
      Speed up rendering of wide tibbles (#87)
      up test results
      use utf8_width(utf8 = TRUE), closes #68
      bump version to 1.0.99.9001
      NEWS
      Merge branch 'r-1.0.99.9001' into production
      Merge tag 'v1.0.99.9001'
      bump version to 1.1.0
      NEWS
      CRAN comments
      Merge branch 'r-1.1.0' into production
      Merge tag 'v1.1.0'
      also test on OS X
      manual cache warming and repo handling
      use TRUE and FALSE, closes #95
      fix sigfig computations for numbers >= 1, closes #98
      restrict decimal values to at most 13 characters
      remove unused
      fix test
      extract function format_mantissa()
      underline every third digit
      new option pillar.subtle_num
      remove trailing zeros for whole numbers
      fix rare case of misrepresenting the right-hand side with getOption(pillar.sigfig) > 5, closes tidyverse/tibble#380
      fix printing of very small numbers, closes tidyverse/tibble#377
      document and export style_subtle_num()
      bump version to 1.1.0.9000
      NEWS
      Merge branch 'r-1.1.0.9000' into production
      Merge tag 'v1.1.0.9000'
      pin versions
      oops
      underline groups of three, closes #78
      the drake
      forward to format() for classed numerics, closes #88
      use pkginstall for robust installations, minor tweaks
      remove superscript because of poor font support and legibility, closes #90
      print the negation sign adjacent to the number, closes #91
      update pkgdown
      bump version to 1.1.0.9001
      NEWS
      Merge branch 'r-1.1.0.9001' into production
      Merge tag 'v1.1.0.9001'
      bump version to 1.2.0
      NEWS
      up CRAN comments
      up rlang dependency
      up website
      Merge remote-tracking branch 'origin/master' into r-1.2.0
      up docs
      ignore drake dir
      up Windows test results
      up CRAN comments
      oops
      Merge branch 'r-1.2.0' into production
      Merge tag 'v1.2.0'
      patch NEWS
      fix formatting of numeric-like objects with length != 1, closes #88
      bump version to 1.2.1
      NEWS
      up CRAN comments
      rewrite history
      show negative numbers in all red
      add Windows test results
      copy drake tweaks from DBI
      up comments
      up docs
      oops
      Merge branch 'r-1.2.1' into production

Robert Kahne (1):
      Update NEWS.md (#100)

Will Beasley (1):
      update GitHub org in urls

hadley (1):
      Update README badges
@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 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants