Skip to content
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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Add function to format as exponential #652

wants to merge 8 commits into from

Conversation

g1o
Copy link

@g1o g1o commented Mar 28, 2019

The formatExp shows the number as exponential. I hope it can pass the tests now.

g1o added 8 commits March 22, 2019 14:03
Added format exponential function
Use the exponential format in a fixed number of digits
fix regression in formatSignif
Copy link
Member

@yihui yihui left a 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
Copy link
Member

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)
Copy link
Member

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.

Copy link
Author

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);};
Copy link
Member

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.

@shrektan shrektan changed the title Add fuction to format as exponential Add function to format as exponential Jun 13, 2019
@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants