Conversation
Added format exponential function
Use the exponential format in a fixed number of digits
fix regression in formatSignif
yihui
left a comment
There was a problem hiding this comment.
Thanks for the contribution! I guess there is still a bit more work to do.
|
|
||
|
|
||
| #' @export | ||
| #' @rdname formatCurrency |
There was a problem hiding this comment.
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.
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.
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.
| var markInterval = function(d, digits, interval, mark, decMark, precision) { | ||
| var markInterval = function(d, digits, interval, mark, decMark, precision, exponential) { | ||
| 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.
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.