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
Change dollar to print negative sign on the outside; allow percent to work with negative number #40
Conversation
The test that was failing previously was `expect_equal(percent(-0.6), "-60%")`
This change was not obvious by just editing the `scales` package. Rather, when I tried using my edits with `ggplot2`, it turns out that `NA`s are created on the lower and upper bounds so this function needs to gracefully handle `NA`s.
Do this so `nsmall` works the same way for large negative numbers as well as positive.
I personally prefer
|
I like your suggestion to allow for the parentheses. I defer to the package authors on what to do here. |
@@ -53,6 +53,50 @@ test_that("dollar format", { | |||
"$600,000", "$700,000", "$800,000", "$900,000", "$1,000,000")) | |||
expect_equal(dollar(c(9.999)), c("$10")) | |||
expect_equal(dollar(c(99.999)), c("$100")) | |||
expect_equal(dollar(-c(100, 0.23, 1.456565, 2e3)), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests seem a bit repetitive. Could you please reduce and break up into separately named tests?
I'd be happy to review a changes to add a |
Hmmmm, this got a bit more complicated now that |
Well character currency descriptors like USD are usually supposed to come after the number, i.e. http://www.proz.com/forum/linguistics/283051-currency_usd_does_it_come_before_or_after_the_number.html so you would expect people to mainly use characters like USD as a suffix which gives you -500 USD in either case (assuming prefix is then "") instead of the more ugly -USD 500... I think most people (including me and the original patch contributor doug) want negative currency values where the negative sign goes in front of the prefix like -$100 or - £100.45. Both of us have actually written custom formatters to let us do so since that is the format necessary to have good looking charts if you are an economist or business person. If for some reason they don't want it reversed then it should be straightforward to write a custom formatter like
|
I am not sure where the authoritative source on this would be, but how about:
http://english.stackexchange.com/questions/124797/how-to-write-negative-currency-in-text
This commit is to fix #38