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

Indicate whether a value was truncated for displaying or not #362

Closed
lorenzwalthert opened this issue Jan 12, 2018 · 10 comments
Closed

Indicate whether a value was truncated for displaying or not #362

lorenzwalthert opened this issue Jan 12, 2018 · 10 comments
Labels
bug an unexpected problem or unintended behavior

Comments

@lorenzwalthert
Copy link
Contributor

With tibble 1.4.1, the following was unexpected for me:

library(tibble)                                               
data <- tibble(x = 2010:2015, x_plus_a_small_number = x + 0.1)
data                                                          
#> # A tibble: 6 x 2
#>       x x_plus_a_small_number
#>   <int>                 <dbl>
#> 1  2010                  2010
#> 2  2011                  2011
#> 3  2012                  2012
#> 4  2013                  2013
#> 5  2014                  2014
#> 6  2015                  2015

I looked at the pillar package options but I could not figure out how I could force printing more digits.
Is it possible to indicate somehow whether the output of a column was truncated? Maybe with a dot after the value?

#> # A tibble: 6 x 2
#>       x x_plus_a_small_number
#>   <int>                 <dbl>
#> 1  2010                  2010 .
#> 2  2011                  2011 .
#> 3  2012                  2012 .
#> 4  2013                  2013 .
#> 5  2014                  2014 . 
#> 6  2015                  2015 .

And / or providing a package option that allows to print the full value?

@lorenzwalthert
Copy link
Contributor Author

Related: #361

@lorenzwalthert lorenzwalthert changed the title Indicate whether a value was truncated or not Indicate whether a value was truncated for displaying or not Jan 12, 2018
@krlmlr
Copy link
Member

krlmlr commented Jan 12, 2018

Does options(pillar.sigfig = 6) change the output? This seems related to r-lib/pillar#40.

@lorenzwalthert
Copy link
Contributor Author

I can't see anything different.

@krlmlr
Copy link
Member

krlmlr commented Jan 14, 2018

Oh, this needs the dev version of pillar.

@lorenzwalthert
Copy link
Contributor Author

With recent dev versions of pillar and tibble, I get this.

options(pillar.sigfig = 6)
library(pillar)
data <- tibble::tibble(x = 2010:2015, x_plus_a_small_number = x + 0.1)
data
#> # A tibble: 6 x 2
#>       x x_plus_a_small_number
#>   <int>                 <dbl>
#> 1  2010                  2010
#> 2  2011                  2011
#> 3  2012                  2012
#> 4  2013                  2013
#> 5  2014                  2014
#> 6  2015                  2015
data$x_plus_a_small_number
#> [1] 2010.1 2011.1 2012.1 2013.1 2014.1 2015.1
tibble::as_tibble(mtcars)
#> # A tibble: 32 x 11
#>        mpg     cyl   disp       hp    drat      wt    qsec      vs      am
#>  *   <dbl>   <dbl>  <dbl>    <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
#>  1 21.0000 6.00000 160.00 110.00   3.90000 2.62000 16.4600 0       1.00000
#>  2 21.0000 6.00000 160.00 110.00   3.90000 2.87500 17.0200 0       1.00000
#>  3 22.8000 4.00000 108.00  93.0000 3.85000 2.32000 18.6100 1.00000 1.00000
#>  4 21.4000 6.00000 258.00 110.00   3.08000 3.21500 19.4400 1.00000 0      
#>  5 18.7000 8.00000 360.00 175.00   3.15000 3.44000 17.0200 0       0      
#>  6 18.1000 6.00000 225.00 105.00   2.76000 3.46000 20.2200 1.00000 0      
#>  7 14.3000 8.00000 360.00 245.00   3.21000 3.57000 15.8400 0       0      
#>  8 24.4000 4.00000 146.70  62.0000 3.69000 3.19000 20.0000 1.00000 0      
#>  9 22.8000 4.00000 140.80  95.0000 3.92000 3.15000 22.9000 1.00000 0      
#> 10 19.2000 6.00000 167.60 123.00   3.92000 3.44000 18.3000 1.00000 0      
#> # ... with 22 more rows, and 2 more variables: gear <dbl>, carb <dbl>
sessioninfo::session_info()
#> ─ Session info ──────────────────────────────────────────────────────────
#>  setting  value                       
#>  version  R version 3.4.3 (2017-11-30)
#>  os       macOS Sierra 10.12.1        
#>  system   x86_64, darwin15.6.0        
#>  ui       X11                         
#>  language (EN)                        
#>  collate  en_US.UTF-8                 
#>  tz       Europe/Zurich               
#>  date     2018-01-14                  
#> 
#> ─ Packages ──────────────────────────────────────────────────────────────
#>  package     * version     date       source                            
#>  assertthat    0.2.0       2017-04-11 CRAN (R 3.4.0)                    
#>  backports     1.1.2       2017-12-13 CRAN (R 3.4.3)                    
#>  cli           1.0.0       2017-11-05 CRAN (R 3.4.2)                    
#>  clisymbols    1.2.0       2017-05-21 CRAN (R 3.4.0)                    
#>  crayon        1.3.4       2017-09-16 CRAN (R 3.4.1)                    
#>  digest        0.6.13      2017-12-14 CRAN (R 3.4.3)                    
#>  evaluate      0.10.1      2017-06-24 CRAN (R 3.4.1)                    
#>  htmltools     0.3.6       2017-04-28 CRAN (R 3.4.0)                    
#>  knitr         1.18        2017-12-27 CRAN (R 3.4.3)                    
#>  magrittr      1.5         2014-11-22 CRAN (R 3.4.0)                    
#>  pillar      * 1.0.99.9001 2018-01-14 Github (r-lib/pillar@9d96835)     
#>  Rcpp          0.12.14     2017-11-23 CRAN (R 3.4.3)                    
#>  rlang         0.1.6       2017-12-21 CRAN (R 3.4.3)                    
#>  rmarkdown     1.8         2017-11-17 CRAN (R 3.4.2)                    
#>  rprojroot     1.3-2       2018-01-03 CRAN (R 3.4.3)                    
#>  sessioninfo   1.0.1       2017-09-06 Github (r-lib/sessioninfo@e813de4)
#>  stringi       1.1.6       2017-11-17 CRAN (R 3.4.2)                    
#>  stringr       1.2.0       2017-02-18 CRAN (R 3.4.0)                    
#>  tibble        1.4.1.9000  2018-01-14 Github (tidyverse/tibble@590c0de) 
#>  utf8          1.1.3       2018-01-03 CRAN (R 3.4.3)                    
#>  withr         2.1.1       2017-12-19 CRAN (R 3.4.3)                    
#>  yaml          2.1.16      2017-12-12 CRAN (R 3.4.3)

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

@krlmlr
Copy link
Member

krlmlr commented Feb 7, 2018

The pillar.sigfig options seems to be off by (at least) one.

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

krlmlr commented Feb 9, 2018

The trailing dot is implemented in the dev version of pillar.

@krlmlr krlmlr closed this as completed Feb 9, 2018
@lorenzwalthert
Copy link
Contributor Author

lorenzwalthert commented Mar 2, 2018

Ok. I meant it the other way though. Maybe it's too late to flip the meaning again, but I find it a bit confusing.
Alternative: Can't we put a tilde at the end to indicate we are abbreviating? Then, it would be consistent with strings. Because for me, the dot indicates that we cut away something, so we removed some decimal points, which is exactly the opposite of the current behaviour.

@krlmlr
Copy link
Member

krlmlr commented Mar 2, 2018

Happy to discuss improvements in a new or existing issue, preferably in the pillar package. Perhaps increasing the pillar.sigfig option will help in your use case?

@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