-
Notifications
You must be signed in to change notification settings - Fork 109
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
label_number() argument to always print number with sign #262
Comments
Happy to help here and send the PR. I see at least two options.
scales::label_number(show_plus_sign = TRUE)(seq(-1, 1, 0.5))
plus_sign <- function(x) ifelse(x >= 0, "+", "")
scales::label_number(prefix = plus_sign)(seq(-1, 1, 0.5)) Both options would be backwards compatible. Any other ideas or preferences? |
Hi @dirkschumacher - thanks for your offer of help! I think these are both good options. I have a strong preference for (1), because showing a plus sign is quite a universal concept (i.e. independent of the prefix or suffix). But I'd definitely like to get feedback from the package maintainers before opening a PR. As is often the case, naming this new argument is probably the most difficult bit. Here are some ideas:
|
Currently,
label_number()
only prints negative numbers with a sign. I'm requesting an argument to force a+
symbol before positive numbers.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):scales/R/label-number.r
Lines 154 to 163 in 1e2c918
One open question is whether zero should get
+
,-
or nothing? Thesprintf()
function suggests that we should use+
. This is also consistent with Python and C.So I think I'm suggesting something like:
The text was updated successfully, but these errors were encountered: