pillar 1.2.1

  r-lib, tibble, pillar

  Kirill Müller, Hadley Wickham

We’re excited to present version 1.2.1 of the pillar package, the package that is responsible for printing tibbles to the terminal. This small release addresses feedback concerning the output of tibbles. In particular, groups of three digits are now highlighted to give a better idea about the order of magnitude of decimal numbers. In addition, a few minor bugs were fixed, such as the output for S3 classes extending numeric (like durations from lubridate) and the output very small numbers.

Please see the release notes for the full list of improvements and bug fixes. Because the changes in this package mostly affect the output for tibbles, examples in this blog post are shown using the tibble package.

Improved output

In response to use feedback, the following changes were made to the output:

  • Previous versions of pillar showed all but the three “significant” digits in a subtle color. This highlights the wrong digits in some common use cases and is now turned off by default.
  • The negation sign is printed next to the number again. Aligning all negation signs turned out to be confusing in some cases.
  • 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.
x <- -123456789 * (10 ^ c(-2, -5, -6, NA, -8, -10)) * c(-1, 1)
x
#> [1]  1.234568e+06 -1.234568e+03  1.234568e+02            NA  1.234568e+00
#> [6] -1.234568e-02
tibble(x)
#> # A tibble: 6 x 1
#>               x
#>           <dbl>
#> 1  1234568.    
#> 2    -1235.    
#> 3      123.    
#> 4       NA     
#> 5        1.23  
#> 6       -0.0123
  • Scientific notation uses regular digits again for exponents, to improve legibility and because in some common fonts the superscript digits aren’t aligned correctly.
print(tibble(x), width = 15)
#> # A tibble: 6
#> #   x 1
#>              x
#>          <dbl>
#> 1      1.23e+6
#> 2     -1.23e+3
#> 3      1.23e+2
#> 4     NA      
#> 5      1.23e+0
#> 6     -1.23e-2

To avoid confusion, the decimal dot is now always printed for numbers of type numeric, but trailing zeros are no longer shown if all displayed numbers are whole numbers. Compare the following outputs:

whole <- c(1, 3, 5)
tibble(whole)
#> # A tibble: 3 x 1
#>   whole
#>   <dbl>
#> 1    1.
#> 2    3.
#> 3    5.
tibble(wholeish = whole + 0.00000001)
#> # A tibble: 3 x 1
#>   wholeish
#>      <dbl>
#> 1     1.00
#> 2     3.00
#> 3     5.00

Bug fixes

Are you a lubridate user? Durations and other objects are displayed again:

tibble(duration = lubridate::as.duration(1:3))
#> # A tibble: 3 x 1
#>   duration      
#>   <S4: Duration>
#> 1 1s            
#> 2 2s            
#> 3 3s

(This also works for other data types that extend numeric but don’t implement a pillar_shaft() method. See the “Extending tibble” vignette for details on providing better support for printing your data type in a tibble.)

Very small numbers are now printed correctly.

tiny <- c(1e-310, 1e-320, 1e-330)
tiny
#> [1] 1.000000e-310 9.999889e-321  0.000000e+00
tibble(tiny)
#> # A tibble: 3 x 1
#>         tiny
#>        <dbl>
#> 1  1.00e-310
#> 2 10.00e-321
#> 3  0.   

Tibble or pillar?

Now that pillar is responsible for generating the output for tibbles, what is the best place to discuss problems or suggest ideas?

As usual, if you’re not sure if a particular behavior is intended, StackOverflow is a good place to ask, use the [r] and [tibble] tags and perhaps the [tidyverse] tag. Include a reproducible example, perhaps using the reprex package with a reprex::reprex(venue = "so") call.

To submit bugs or suggest ideas for the output of tibbles, use the tibble issue tracker, your contributions are always welcome. Add a reprex with reprex::reprex(). Unfortunately, the reprex package doesn’t support rendering color and font effects yet, please include a screenshot if these details matter for your example.

If you are developing a package that uses pillar, or if you are sure that you have found a problem in this package, you can also use the pillar issue tracker. Please restrict your reprex to the pillar package in these situations.

Acknowledgments

We’d like to use the opportunity to thank all contributors to pillar since its inception. Thanks to everyone, your feedback is very valuable to us: @adsaxon, @benmarwick, @brodieG, @cboettig, @DavisVaughan, @dpeterson71, @echasnovski, @edzer, @ijlyttle, @jennybc, @leondutoit, @lionel-, @martinjhnhadley, @PMassicotte, @randomgambit, @rkahne, @strengejacke, @tmelconian, and @wibeasley.