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

turn off tibble number printing enhancements #417

Closed
DasHammett opened this issue Jun 2, 2018 · 5 comments
Closed

turn off tibble number printing enhancements #417

DasHammett opened this issue Jun 2, 2018 · 5 comments

Comments

@DasHammett
Copy link

DasHammett commented Jun 2, 2018

Hi,

Is there a way to disable all printing "enhancements" from tibble? Probably look fantastic in RStudio, but there are still people who do not use it it just a pain to watch on a terminal R session

> mtcars %>% as_tibble()
# A tibble: 32 x 11
     mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb
 * <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
 1  21       6 160     110  3.9   2.62  16.5     0     1     4     4
 2  21       6 160     110  3.9   2.88  17.0     0     1     4     4
 3  22.8     4 108      93  3.85  2.32  18.6     1     1     4     1
 4  21.4     6 258     110  3.08  3.22  19.4     1     0     3     1
 5  18.7     8 360     175  3.15  3.44  17.0     0     0     3     2
 6  18.1     6 225     105  2.76  3.46  20.2     1     0     3     1
 7  14.3     8 360     245  3.21  3.57  15.8     0     0     3     4
 8  24.4     4 147.     62  3.69  3.19  20       1     0     4     2
 9  22.8     4 141.     95  3.92  3.15  22.9     1     0     4     2
10  19.2     6 168.    123  3.92  3.44  18.3     1     0     4     4
11  17.8     6 168.    123  3.92  3.44  18.9     1     0     4     4
12  16.4     8 276.    180  3.07  4.07  17.4     0     0     3     3
13  17.3     8 276.    180  3.07  3.73  17.6     0     0     3     3
14  15.2     8 276.    180  3.07  3.78  18       0     0     3     3
15  10.4     8 472     205  2.93  5.25  18.0     0     0     3     4
16  10.4     8 460     215  3     5.42  17.8     0     0     3     4
17  14.7     8 440     230  3.23  5.34  17.4     0     0     3     4
18  32.4     4  78.7    66  4.08  2.2   19.5     1     1     4     1
19  30.4     4  75.7    52  4.93  1.62  18.5     1     1     4     2
20  33.9     4  71.1    65  4.22  1.84  19.9     1     1     4     1
21  21.5     4 120.     97  3.7   2.46  20.0     1     0     3     1
22  15.5     8 318     150  2.76  3.52  16.9     0     0     3     2
23  15.2     8 304     150  3.15  3.44  17.3     0     0     3     2
24  13.3     8 350     245  3.73  3.84  15.4     0     0     3     4
25  19.2     8 400     175  3.08  3.84  17.0     0     0     3     2
26  27.3     4  79      66  4.08  1.94  18.9     1     1     4     1
27  26       4 120.     91  4.43  2.14  16.7     0     1     5     2
28  30.4     4  95.1   113  3.77  1.51  16.9     1     1     5     2
29  15.8     8 351     264  4.22  3.17  14.5     0     1     5     4
30  19.7     6 145     175  3.62  2.77  15.5     0     1     5     6
31  15       8 301     335  3.54  3.57  14.6     0     1     5     8
32  21.4     4 121     109  4.11  2.78  18.6     1     1     4     2

I have multiple issues with this:

  • Why defining significant decimals in the first place? Why 3 and not 4 or 5? -I really can't understand why this is a good idea.
  • Why all the fancy formatting such as greyed out or red numbers. Align around the decimal point? It adds very little and just makes it more difficult to read
  • Why different different decimal places on the same column? It just makes it more difficult to read
  • Why automatic rounding? Look at disp column and you'll see automatic rounding for no reason.

I have been looking around for options (pillar.sigfig and pillar.subtle) but haven't found any to disable for example the automatic rounding on the disp column. I find these extremely confusing and difficult to read and heck, can't lead to wrong decisions as (depending on the situation) there can be a big difference between a rounded and not rounded result.

I just don't want to add as_data_frame() at the end of each pipe to get rid of this...

Thank you

Kind regards,

@cderv
Copy link
Contributor

cderv commented Jun 2, 2018

one known and advertise way to deactivate is to overide print.tbl_df method
see https://www.tidyverse.org/articles/2018/04/pillar-1-2-2/

if you define this on top of your script or in your R session, you'll be good!

Don’t like the printing?

Just like with the absence of row names or the default drop = FALSE, tibbles are opinionated in how they print. We’re working on providing a sensible default that suits most use cases, but some users have expressed the desire to revert to the good old data frame output.

This is possible already by overriding the print.tbl_df method, which is called when a tibble is printed (either explicitly via print() or implicitly from the console). On the downside, this also loses the second header row with the data types and the restriction in the number of rows and columns shown.

Some options can already be set to change some of the printing. See options page on pillar website. You may know that as you already try some of them.

@DasHammett
Copy link
Author

Hi @cderv,

Thanks for your reply. I had a look at the links you provided. I didn't know the overide of print.tbl_df.

Is there a way we can choose what is printed? I particularly like the printing of tibble 1.3, where we can see the secondary header with column type information without all the messy printing introduced in latest tibble

If I have to chose between the current tibble printing and a flat, df printing, I definitely chose the latter.

Thanks

Kind regards

@cderv
Copy link
Contributor

cderv commented Jun 2, 2018

I think you either override the printing or change what can be changed with the current options.
Currently, I don't think you can keep only the column type header and none of the rest. There is no option for that. Sorry.

I think you should choose the overide option with maybe a custom print with only the secondary header.
That way you'll have your prefered and own printing 😉

@krlmlr
Copy link
Member

krlmlr commented Jun 6, 2018

Thanks Christophe for chiming in. Yes, it's currently all-or-nothing, we're working on a way to make the output configurable in #411. (Numbers can have very different meanings, it's difficult to come up with a setting that fits all use cases.)

Coloring can be disabled with options(crayon.enabled = FALSE), but that affects coloring in other packages too.

A more subtle way to change the formatting only for numbers is to override pillar_shaft.numeric() instead. See the first implementation for pillar_shaft.latlon() in the "extending" vignette, a simple implementation for numbers would call format() or formatC() with your preferred settings and then forward to new_pillar_shaft_simple(), just like the vignette code does for the "latlon" class.

@krlmlr krlmlr closed this as completed Jun 6, 2018
@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
None yet
Projects
None yet
Development

No branches or pull requests

3 participants