Skip to content
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] Inline formatting for percentages #706

Open
tzakharko opened this issue Jul 24, 2024 · 1 comment
Open

[feature] Inline formatting for percentages #706

tzakharko opened this issue Jul 24, 2024 · 1 comment
Labels
feature a feature request or enhancement

Comments

@tzakharko
Copy link
Contributor

I find myself frequently reporting proportions as percentages, so it would be nice if cli supported a .percent formatter out of the box. @gaborcsardi would it be ok if I submitted a pull request for this?

@gaborcsardi
Copy link
Member

Thanks! Ideally we would have a (better) way for people to define their own formatters, instead of putting everything in cli.

Also, for percentages, you can use the scales package, or define your own simple function that does the formatting, and call it from the format string:

pct <- scales::label_percent()
n <- .65
cli::cli_text("{pct(n)} percent of percentages are larger than {pct(.5)}.")
#> 65% percent of percentages are larger than 50%.

@gaborcsardi gaborcsardi added the feature a feature request or enhancement label Feb 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants