gt icon indicating copy to clipboard operation
gt copied to clipboard

Let users customize order of `suffixing` and `currency` (or other eurs)

Open maxheld83 opened this issue 1 year ago • 2 comments

Prework

Proposal

Currently,

gt::vec_fmt_currency(1000L, "EUR", suffixing = TRUE, placement = "right")
# [1] "1.00EURK"

Where the (German/European?) expectation would be something like "1.00kEUR" or "1.00TEUR" (for thousands).

Also strikes me that in some other contexts outside of currencies, you'd put the suffix before the unit, not after (milliampers, "mA", not "Am").

So it might be cool to let users customize this order.

maxheld83 avatar Jul 18 '24 10:07 maxheld83

I assume this is rather a bug instead of intended behaviour. Right now I can think of no use-case to split the number itself and a suffix in favour of a symbol of any kind.

All other formatting functions that use symbols ("%" for example) internally set "suffixing" to FALSE before calling fmt_symbol. But even if they'd apply suffixing, "2k %" would make more sense than "2 %k"

I'd suggest to rework the order here: https://github.com/rstudio/gt/blob/33e9d62bc8fccc480c603fc85e27011b5501939d/R/format_data.R#L1190C1-L1210C64

What do you think @rich-iannone ?

obsaditelnost avatar Sep 04 '24 00:09 obsaditelnost

A number/currency overhaul needs to be done here. First, the short/compact numbers aren't localized. The currency symbol placement also isn't localized. The combination of this, a short/compact currency pattern also needs to be added. The data is available for all of this. For your specific example (in the "de" locale), this is what it should ideally look like:

https://github.com/unicode-org/cldr-json/blob/d38478855dd8342749f0494332cc8acc2895d20d/cldr-json/cldr-numbers-full/main/de/numbers.json#L121

rich-iannone avatar Sep 18 '24 00:09 rich-iannone