-
Notifications
You must be signed in to change notification settings - Fork 38
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
control over < > for print.tbl_df method #73
Comments
You can define your own |
A fully unit-ized suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(units))
library(tibble)
options(width = 100)
mtcars %>%
mutate(mpg = set_units(mpg, mile/gallon),
cyl = set_units(cyl),
disp = set_units(disp, `in`^3),
hp = set_units(hp, hp),
drat = set_units(drat),
wt = set_units(wt, klb),
qsec = set_units(qsec, s),
vs = set_units(vs, V/S),
am = c("aut", "man")[am+1],
gear = set_units(gear),
carb = set_units(carb)
) %>%
as.tibble %>%
print(width = 100) which is nice! However, the |
In this case, it seems a bit duplicative to have the type in the heading and next to every individual value. |
I wonder if it's worth never applying the |
(I updated my comment above to show the output without units behind each value) |
I wonder if we could parse the value returned by
In strengejacke/sjlabelled#3 (comment) I was suggesting a
But I'm no longer sure how useful a custom multiline column header would be, given the very limited space available in a terminal. |
@edzer @etiennebr: Did we discuss that an attribute in the value returned by a |
Yes, we discussed it. If I remember correctly we discussed making something like |
Thanks for the reminder, the new CC @strengejacke. |
This works without brackets, but it seems to break if I specify square brackets in the type_sum, as in type_sum.units <- function(x, ...) {
structure(paste0("[", as.character(units(x)), "]"), class = "type_sum_units")
} In this case, the last two characters are bitten off. |
library(pillar)
type_sum.accel <- function(x) {
structure("kg m/s^2", class = "type_sum_accel")
}
format_type_sum.type_sum_accel <- function(x) {
style_subtle(x)
}
accel <- structure(9.81, class = "accel")
pillar(accel)
#> kg m/s
#> 9.81
|
Thanks for the heads-up, I'll work on a fix. |
What's a good way to turn your output into runnable code? |
🤦♂️🤦♂️ It's just the example for |
Thanks a lot, @krlmlr! |
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. |
The standard way to print units of measure is between square brackets, as in
[km/h]
. When I do this in a tibble header, I get<[km/h]>
, which looks odd (example below) and takes unnecessary space. Is there a way to get rid of the<
and>
? Should I raise this issue withtibble
?The text was updated successfully, but these errors were encountered: