Allow rounding of numbers in output when quantities include "percentage"#101
Open
xiaosongz wants to merge 1 commit intojolars:mainfrom
Open
Allow rounding of numbers in output when quantities include "percentage"#101xiaosongz wants to merge 1 commit intojolars:mainfrom
xiaosongz wants to merge 1 commit intojolars:mainfrom
Conversation
jolars
requested changes
Dec 8, 2022
Owner
jolars
left a comment
There was a problem hiding this comment.
Thanks for this PR! But see my comments. Could you also please make this work for non-percentage quantities too?
| if ("percent" %in% type) { | ||
| perc <- num/sum(num, na.rm = TRUE)*100 | ||
| perc <- ifelse(perc >= 1, as.character(round(perc)), "< 1") | ||
| perc <- ifelse(perc >= 1, as.character(round(perc,round)), "< 1")# add rounding option to adjust precision of percentage |
Owner
There was a problem hiding this comment.
Suggested change
| perc <- ifelse(perc >= 1, as.character(round(perc,round)), "< 1")# add rounding option to adjust precision of percentage | |
| perc <- ifelse(perc >= 1, as.character(round(perc, round)), "< 1") |
| digits <- options("digits")$digits | ||
|
|
||
| # get round parameter from options("round"), if not set, use default value 0 | ||
| round <- ifelse(is.null(options("round")$round) != TRUE, |
Owner
There was a problem hiding this comment.
Suggested change
| round <- ifelse(is.null(options("round")$round) != TRUE, | |
| round <- ifelse(!is.null(options("round")$round), |
Owner
There was a problem hiding this comment.
Can you please use the eulerr_options() interface instead? https://github.com/jolars/eulerr/blob/main/R/eulerr_options.R
I don't think it would be a good idea to add just "round" to the global options. It could easily be overwritten by something else.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#76
#75
allow round quantities("percentage") using global parameter
options("round")$round.roundwill be set as0if global parameteroptions("round")$roundnot set.