Comments (6)
I had a look through the code to see if I could implement this myself, but there were a few too many layers of indirection for me to follow. If you can point me to the appropriate place in the code, I can try implementing this when I have time.
from pillar.
Thanks. The prt package implements output in this way, see, e.g., https://github.com/nbenn/prt/blob/main/tests/testthat/_snaps/format.md .
CC @nbenn.
from pillar.
Interesting. So it looks like I could potentially define my own print method for data frames and/or tibbles that calls prt::format_dt
. Is there an easy way to determine if a given tibble's backend supports efficient random access so that I can avoid trying to e.g. get the tail of a database query result?
from pillar.
None that I'm aware of, perhaps you could implement some heuristics? Happy to review if you'd be willing to share an implementation.
from pillar.
I will definitely share if I figure it out. Do you have any opinions on how the options should be set up?
from pillar.
A minimal implementation for tibbles, meant to be put in ~/.Rprofile
:
print.tbl <- function (x, width = NULL, ..., n = NULL, max_extra_cols = NULL, max_footer_lines = NULL) {
tryCatch({
n_half <- if(!is.null(n)) ceiling(n/2)
prt:::cat_line(prt:::format_dt(x = x, ..., n = n_half, width = width, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines))
}, error = \(...) pillar:::print.tbl(x = x, width = width, ..., n = n, max_extra_cols = max_extra_cols, max_footer_lines = max_footer_lines))
}
I also came up with something for base data frames, but I print them using the aforementioned S4Vectors code, since the dplyr/pillar stuff doesn't print row names, which can't be ignored for base data frames.
print.data.frame <- function(x, ...) {
tryCatch({
withr::with_options(
list(max.print = ncol(x) * 15),
S4Vectors:::.show_DataFrame(x)
)
}, error = \(...) base::print.data.frame(x = x, ...))
}
from pillar.
Related Issues (20)
- 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
- 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
- logic of pillar.print_max pillar.print_min
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.