rstudio / gt

Easily generate information-rich, publication-quality tables from R
https://gt.rstudio.com
Other
1.98k stars 200 forks source link

Allow `suffixing` of `vec_fmt_*()` to accept custom scales and suffixes #1026

Open zenggyu opened 2 years ago

zenggyu commented 2 years ago

Prework

Proposal

First of all, thanks for providing the vec_fmt_*() functions! This is going to be so useful when making quarto/rmarkdown reports.

For non-English users, there's a good chance that the existing suffixes (K, M, B, T) for vec_fmt_number(), etc. is not a good choice for local readers. However, currently there's no way to change the scaling factors along with the suffixing characters. I suggest allowing the use of named vectors for the suffixing option to achieve the goal. For example, to define a list of large numbers in ten thousands (with suffix "w") and a hundred millions (with suffix "y"), one would write: vec_fmt_number(x, suffixing = c("w" = 10000, "y" = 100000000)).

zenggyu commented 2 years ago

For reference, see the scale_cut option in scales::label_number().

rich-iannone commented 1 year ago

Thank you @zenggyu , this seems very reasonable and is a good idea as well!