GithubHelp home page GithubHelp logo

Comments (8)

strengejacke avatar strengejacke commented on July 18, 2024

Another example: When I print the vector alone, the desired output is shown:

library(tibble)
x <- tibble(a = c(1, 2, 3), b = c(1L, 2L, 3L), c = c(1.23, 1.34, 1.45))
x$a
#> [1] 1 2 3
x$b
#> [1] 1 2 3
x$c
#> [1] 1.23 1.34 1.45

Same behaviour would be nice for tibbles as well - I hope you think this makes sense.

from pillar.

krlmlr avatar krlmlr commented on July 18, 2024

@hadley: Should we omit the dot and the zeros after the dot if we only see whole numbers? Current output:

pillar::pillar(as.numeric(1:3))
#> <dbl>
#>  1.00
#>  2.00
#>  3.00

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

from pillar.

hadley avatar hadley commented on July 18, 2024

Hmmm, I don't think it's a good idea to do this. For performance reasons, we can only inspect the rows being printed, so this seems potentially misleading to me.

from pillar.

krlmlr avatar krlmlr commented on July 18, 2024

I've thought about that, too. What's the chance that a column contains fractions if the first 10 entries don't have any? If we assume that only .0 and .5 are present, and a uniform distribution, that's < 0.1%. If we assume .0 through .9, that's 10โปยนโฐ. We have the type indicator, too.

The digits.secs option also triggers fractional seconds only for the displayed data.

We can really fix this only if the column contains some metadata that describes all values.

Maybe make this an option? Printing only the dot but not the trailing zeros doesn't look appealing to me:

pillar::pillar(as.numeric(1:3))
#> <dbl>
#>    1.
#>    2.
#>    3.

from pillar.

hadley avatar hadley commented on July 18, 2024

Based on readr experience, quite high.

I'd rather not add more options.

from pillar.

 avatar commented on July 18, 2024

I'd agree with @hadley, that there are many cases where the first 10 entries don't include any digits to the right of the decimal, while somewhere in the data they do, but I'm not sure that's more common than the other way around. You may be trying to avoid a common but minority misrepresentation by using a method that misrepresents the data the majority of the time.

I understand the performance benefit for only checking the rows that are printed. If that's the way pillar displays data (check the rows you print), why not have that be the data you're representing (the rows you print)?

Trailing zeros have a meaning. They mean somewhere in this data there is an entry with values to the right of the decimal. If printing using pillar is supposed to give you information about ALL the data (instead of just the data it prints) while only checking a portion, you're either going to have to find some magic, cache the checks of the entire data when an object is created (change other packages), or decide between two cases where the wrong meaning is displayed (as a trade off for the performance). In one case the display tells you there are later, unprinted entries with values to the right of the decimal (when there aren't); in the other case the display tells you there are no later unprinted entries with values to the right of the decimal (when there are). I'm not sure it's clear that the second option (the new way tibbles print) is better than the first.

I'd also add that this behavior for data with no values to the right of the decimal is not the way printing that same data was handled by tibbles previously. So, though different things surprise different people, this will be surprising (at least for a while) for most users of the tidyverse.

from pillar.

krlmlr avatar krlmlr commented on July 18, 2024

Closing in favor of #40: Adding a trailing dot but without decimals in these cases.

from pillar.

github-actions avatar github-actions commented on July 18, 2024

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.

from pillar.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.