-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Support zero-length vectors in case_when() #3048
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
Conversation
tests/testthat/test-case-when.R
Outdated
@@ -32,7 +32,7 @@ test_that("cases must yield compatible lengths", { | |||
c(TRUE, FALSE) ~ 1, | |||
c(FALSE, TRUE, FALSE) ~ 2 | |||
), | |||
"LHS of case 1 (`c(TRUE, FALSE)`) must be length 3 (the longest input) or one, not 2", | |||
"All conditions and values must be length 1 or 2 (the first non-atomic value), not 3", |
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'd say remove the parenthetical ("(the first non-atomic value)") and be more precise about the failures:
All conditions and values must be length 1 or 2.
Problems at the following locations: 2.
@hadley: The error message now quotes the failing arguments verbatim, for consistency with other error messages. |
This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/ |
Closes #3041.
The second commit is optional, it simplifies error handling but the message is less verbose.