-
Notifications
You must be signed in to change notification settings - Fork 25
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
Added value_type argument to choose what value to display #6
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.
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 |
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.
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))) | |||
|
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.
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") { |
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.
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), |
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.
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", |
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.
Do you think show_percentage = TRUE is better than value_type = "both"?
@@ -0,0 +1,17 @@ | |||
Version: 1.0 |
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.
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.
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").