-
Notifications
You must be signed in to change notification settings - Fork 116
Closed
Labels
featurea feature request or enhancementa feature request or enhancementhelp wanted ❤️we'd love your help!we'd love your help!
Milestone
Description
Currently, label_number() only prints negative numbers with a sign. I'm requesting an argument to force a + symbol before positive numbers.
> scales::label_number()(seq(-1, 1, 0.5))
[1] "-1.00" "-0.50" "0.00" "0.50" "1.00"The base R format() method doesn't provide an argument for this, so it's not currently possible to achieve this with dot args. Probably it would need to be added in post-processing between these lines (i.e. before adding a prefix):
Lines 154 to 163 in 1e2c918
| ret <- format( | |
| scale * x, | |
| big.mark = big.mark, | |
| decimal.mark = decimal.mark, | |
| trim = trim, | |
| nsmall = nsmall, | |
| scientific = FALSE, | |
| ... | |
| ) | |
| ret <- paste0(prefix, ret, suffix) |
One open question is whether zero should get +, - or nothing? The sprintf() function suggests that we should use +. This is also consistent with Python and C.
So I think I'm suggesting something like:
ret <- ifelse(x >= 0, paste0("+", ret), ret)Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
featurea feature request or enhancementa feature request or enhancementhelp wanted ❤️we'd love your help!we'd love your help!