Skip to content

Conversation

@xiaosongz
Copy link

#76
#75

allow round quantities("percentage") using global parameter options("round")$round.
round will be set as 0 if global parameter options("round")$round not set.

Copy link
Owner

@jolars jolars 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 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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
round <- ifelse(is.null(options("round")$round) != TRUE,
round <- ifelse(!is.null(options("round")$round),

Copy link
Owner

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.

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.

2 participants