Skip to content

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

Merged
merged 6 commits into from
Aug 23, 2017

Conversation

krlmlr
Copy link
Member

@krlmlr krlmlr commented Aug 23, 2017

Closes #3041.

The second commit is optional, it simplifies error handling but the message is less verbose.

@krlmlr krlmlr requested a review from hadley August 23, 2017 08:56
@@ -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",
Copy link
Member

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.

@krlmlr
Copy link
Member Author

krlmlr commented Aug 23, 2017

@hadley: The error message now quotes the failing arguments verbatim, for consistency with other error messages.

@krlmlr krlmlr merged commit e66ddd6 into tidyverse:master Aug 23, 2017
@krlmlr krlmlr deleted the b-#3041-case-when-zero branch August 23, 2017 18:02
@lock
Copy link

lock bot commented Jan 18, 2019

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/

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants