Comments (8)
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.
@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.
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.
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.
Based on readr experience, quite high.
I'd rather not add more options.
from pillar.
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.
Closing in favor of #40: Adding a trailing dot but without decimals in these cases.
from pillar.
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)
- Very small numbers print as `Inf.e-324` HOT 6
- Should `*` or `i` be used for footer information? HOT 11
- Truncated list-cols don't seem to get grey coloring HOT 2
- pillar_num and logical vectors cause (potential?) issues
- Installation of pillar 1.9.0 in GitHub actions fails HOT 2
- Should time zones be changing datetime formatting?
- Conditional colouring of values in specific columns HOT 2
- Infinite date-time being printed twice
- Why do `new_pillar_shaft()` and `new_pillar_shaft_simple()` default `min_width` to `width`? HOT 1
- FR: don't print seconds in dttm if there is not enough space
- FR: Add a pillar.max_chars option HOT 1
- Modify tbl_df subclass print in a package HOT 2
- Feature request: Option to print both head and tail of tables? HOT 6
- Use pillar to make column titles red HOT 1
- Guidance colorizing values within a column HOT 2
- The output of `glimpse()` is too wide in RStudio Visual Editor mode HOT 6
- Show colour in `glimpse()` HOT 2
- pillar::num type vector is not properly treated by base::sum (with respect to na.rm=TRUE) HOT 1
- Some changes make warnings in tibble
- Please add col number to glimpse output HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pillar.