Closed konradzdeb closed 2 years ago
The code:
d <- tibble(value = c(1, 2, 3, 5, 6, 7, 8, 9), `Set 1` = c(TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE), `Set 2` = c(TRUE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE), `Set 3` = c(TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, TRUE, TRUE), `Set 4` = c(FALSE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE)) ggvenn(d, c("Set 1", "Set 2"), show_elements = TRUE)
Would return error message reflecting is.character call evaluating to FALSE in stopifnot. stopifnot is only a convenience function for call:
is.character
FALSE
stopifnot
if(!all(conditions)) stop(any message)
receiving notification that is.character returns FALSE the user could be tempted to run
ggvenn(d, c("Set 1", "Set 2"), show_elements = "TRUE")
This is unhelpful as the real problem is associated with the value not corresponding to the data frame column.
Informative error message leading to solution irrespectively of whether failure happened at is.character or later
Evaluate the required condition and then return consistent, informative error message.
For a more robust argument checking the `checkmate' provides a better well-painted alternative.
Hi @konradzdeb,
Thank you for your contribution, and I am very sorry for the too late response.
Problem
The code:
Would return error message reflecting
is.character
call evaluating toFALSE
instopifnot
.stopifnot
is only a convenience function for call:receiving notification that
is.character
returns FALSE the user could be tempted to runThis is unhelpful as the real problem is associated with the value not corresponding to the data frame column.
Desired behaviour
Informative error message leading to solution irrespectively of whether failure happened at
is.character
or laterProposed fix
Evaluate the required condition and then return consistent, informative error message.
For a more robust argument checking the `checkmate' provides a better well-painted alternative.