-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Allow rounding of numbers in output when quantities include "percentage" #101
base: main
Are you sure you want to change the base?
Conversation
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 this PR! But see my comments. Could you also please make this work for non-percentage quantities too?
num <- orig[centers$id[singles | others]] | ||
|
||
if (is.null(quantities$labels)) { | ||
type <- quantities$type | ||
|
||
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 |
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.
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") |
@@ -144,14 +144,18 @@ setup_geometry <- function(x, | |||
if (do_quantities) { | |||
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, |
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.
round <- ifelse(is.null(options("round")$round) != TRUE, | |
round <- ifelse(!is.null(options("round")$round), |
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.
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.
#76
#75
allow round quantities("percentage") using global parameter
options("round")$round
.round
will be set as0
if global parameteroptions("round")$round
not set.