-
Notifications
You must be signed in to change notification settings - Fork 181
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
Add function to format as exponential #652
base: main
Are you sure you want to change the base?
Conversation
Added format exponential function
Use the exponential format in a fixed number of digits
fix regression in formatSignif
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.
Thanks for the contribution! I guess there is still a bit more work to do.
@@ -93,6 +96,15 @@ formatSignif = function( | |||
formatColumns(table, columns, tplSignif, digits, interval, mark, dec.mark) | |||
} | |||
|
|||
|
|||
#' @export | |||
#' @rdname formatCurrency |
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.
Please add a brief description of this function on line 18 above.
formatExp = function( | ||
table, columns, digits = 2, interval = 3, mark = ',', dec.mark = getOption('OutDec') | ||
) { | ||
formatColumns(table, columns, tplExp, digits, interval, mark, dec.mark) |
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.
I don't think the arguments interval
, mark
, or dec.mark
will work for formatExp()
. You will have to either drop them or work harder on the markInterval
function in JS.
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.
I don't know either, I would sure need to work harder on them, but most likely I will drop them (as I don't know what they do yet). I just copied the code and made a few changes to got it working.
x = precision ? d.toPrecision(digits) : d.toFixed(digits); | ||
if(exponential) {x = exponential ? d.toExponential(digits) : d.toFixed(digits);}; |
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.
Here d.toFixed(digits)
will never be executed no matter if exponential
is true or false.
|
The formatExp shows the number as exponential. I hope it can pass the tests now.