-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
case_when()
needs to throw a better error when conditions are matrices
#6862
Labels
bug
an unexpected problem or unintended behavior
tidy-dev-day 🤓
Tidyverse Developer Day rstd.io/tidy-dev-day
Comments
Session info:
Session info from other machine that also exhibits the issue:
|
Yea we don't intend for matrices to be passed through as conditions. We probably need an additional check here for Line 54 in 16b472f
|
This comment was marked as off-topic.
This comment was marked as off-topic.
DavisVaughan
changed the title
case_when gives confusing and inconsistent error messages when conditions are matrices
Nov 3, 2023
case_when()
needs to throw a better error when conditions are matrices
DavisVaughan
added
the
tidy-dev-day 🤓
Tidyverse Developer Day rstd.io/tidy-dev-day
label
Jul 22, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
an unexpected problem or unintended behavior
tidy-dev-day 🤓
Tidyverse Developer Day rstd.io/tidy-dev-day
Please briefly describe your problem and what output you expect. If you have a question, please don't use this form. Instead, ask on https://stackoverflow.com/ or https://community.rstudio.com/.
Please include a minimal reproducible example (AKA a reprex). If you've never heard of a reprex before, start by reading https://www.tidyverse.org/help/#reprex.
I had some code that was passing matrices as the conditions to a
case_when
statement. Previously,case_when
would implicitly convert these matrices to vectors, but at some point it stopped doing that. However, I don't think this was an intentional behavior change, because depending on how exactly one callscase_when
on matrix conditions, it can produce one of several different error messages or return a value of the wrong length (see reprex below demonstrating 3 different behaviors). None of the error messages hint at the underlying problem, which made debugging this issue after a package update very difficult.If passing matrices as the conditions to
case_when
is not an intended usage, I would expect it to produce an interpretable error message to that effect.Created on 2023-05-30 with reprex v2.0.2
The text was updated successfully, but these errors were encountered: