-
-
Notifications
You must be signed in to change notification settings - Fork 24
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
[Feature Request]: Add a new format #880
Comments
I do have a idea that we somehow redesign the "xx.x" things, to make it flexible (and translate it into "sprintf"). e.g., "sadbasd asa a xx.xx asda a" translate to "sadbasd asa a %.2f asda a" |
This possibility exists and it is working very fine: library(rtables)
fmtfun <- sprintf_format("this range => %.1f")
format_value(100, format = fmtfun)
fmtfun2 <- sprintf_format("sadbasd asa a %.2f asda a %.1f")
format_value(list(12.23456, 2.724), format = fmtfun2)
lyt <- basic_table() %>%
split_cols_by("Species") %>%
analyze("Sepal.Length", afun = function(x) {
list(
"mean (sd)" = rcell(c(mean(x), sd(x)), format = fmtfun2),
"range" = rcell(diff(range(x)), format = fmtfun)
)
})
> build_table(lyt, iris)
setosa versicolor virginica
—————————————————————————————————————————————————————————————————————————————————————————————————————————
mean (sd) sadbasd asa a 5.01 asda a 0.4 sadbasd asa a 5.94 asda a 0.5 sadbasd asa a 6.59 asda a 0.6
range this range => 1.5 this range => 2.1 this range => 3.0 I think this MUST be better documented though as it is a very powerful and elegant solution to multiple little problems |
oh I mean we have two sets of printing format, one is from "printf_format", one is translating "xx.xx" into "%.2f" so that users could use any "xx.xx" to construct there format (as this is more common in practice for tlg works) |
I see what you mean. I think it is a bit of overhead for little gain as you would use directly |
This essentially falls under factoring formatters format detection into a parser, which is on the roadmap, but a large piece of work we have not yet had the resources to pursue. |
hi @mivanov5 , I think we already have the work-around in #880 (comment), would this work for you? We can look into refactoring and improvement for future work. Thanks! |
Hi @shajoezhu, I made another modification to my program, but guess that as suggested above next time I can create my own format and use its name instead of "xx. - xx.". Hope that anyway it will be added to the formats list at some point. Thanks to @Melkiades for the example and to everyone else for your comments. |
Feature description
In the list of possible formats for ratables/tern functions (produced by
list_valid_format_labels()
, formatters package) the following format is missing:(xx. - xx.)
We have similar formats like
(xx., xx.)
andxx. (xx.%)
, but not the one above.Please add this format.
Code of Conduct
Contribution Guidelines
Security Policy
The text was updated successfully, but these errors were encountered: