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

Added value_type argument to choose what value to display #6

Merged
merged 1 commit into from
Mar 13, 2020
Merged

Added value_type argument to choose what value to display #6

merged 1 commit into from
Mar 13, 2020

Conversation

dhammarstrom
Copy link

value_type in ggvenn makes it possible to chose to only display counts (set value to "counts") compared to both counts and percentages (value_type == "both").

Copy link
Owner

@yanlinlin82 yanlinlin82 left a comment

Choose a reason for hiding this comment

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

Hi dhammarstrom,

Sorry that I replied a little late. Thank you very much for the PR. I have a little suggestion about the code. Could you please help to improve that?

attr <- self$customize_attributes
sets <- c("A", "B", "C", "D")
sets <- sets[sets %in% names(data)]
show_elements <- NA
Copy link
Owner

Choose a reason for hiding this comment

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

If value_type is added to ggvenn(), I strongly suggest adding the same parameter to geom_venn().

@@ -281,7 +283,17 @@ prepare_venn_data <- function(data, columns = NULL, show_elements = FALSE) {
stop("`data` should be a list")
}
if (!show_elements) {
d1 <- d1 %>% mutate(text = sprintf("%d\n(%.1f%%)", n, 100 * n / sum(n)))

Copy link
Owner

Choose a reason for hiding this comment

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

I suggest removing empty lines here.

@@ -164,7 +166,7 @@ gen_label_pos_4 <- function() {
"D", 1.5, -1.3, 0, 1)
}

prepare_venn_data <- function(data, columns = NULL, show_elements = FALSE) {
prepare_venn_data <- function(data, columns = NULL, show_elements = FALSE, value_type = "both") {
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think show_percentage = TRUE is better than value_type = "both"? I personally do not prefer parameters of string type, because it often makes users have to check the manual for valid values before using it.

#' `Set 2` = c(T, F, F, T, F, F, F, T, F, F, T),
#' `Set 3` = c(T, T, F, F, F, F, T, T, F, F, F),
#' `Set 4` = c(F, F, F, F, T, T, F, F, T, T, F))
#' `Set 1` = c(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE),
Copy link
Owner

Choose a reason for hiding this comment

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

Thank you very much to point out my bad writing. TRUE/FALSE is much better than T/F since T/F is not reserved keywords in R.

@@ -47,6 +48,7 @@
#' @export
ggvenn <- function(data, columns = NULL,
show_elements = FALSE,
value_type = "both",
Copy link
Owner

Choose a reason for hiding this comment

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

Do you think show_percentage = TRUE is better than value_type = "both"?

@@ -0,0 +1,17 @@
Version: 1.0
Copy link
Owner

Choose a reason for hiding this comment

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

I am OK to add Rproj files, although I am not using Rstudio very often yet. I am using vim, which has slightly different indent rules. Therefore, I accept the indent changes.

@yanlinlin82 yanlinlin82 merged commit 8961545 into yanlinlin82:master Mar 13, 2020
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