-
Notifications
You must be signed in to change notification settings - Fork 1k
Improve melt error message for invalid measure.vars (#6512) #7549
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
Improve melt error message for invalid measure.vars (#6512) #7549
Conversation
bb9c35c to
ce54940
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #7549 +/- ##
=======================================
Coverage 98.96% 98.96%
=======================================
Files 87 87
Lines 16734 16741 +7
=======================================
+ Hits 16560 16567 +7
Misses 174 174 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
ce54940 to
c313581
Compare
c313581 to
4a82e90
Compare
ben-schwen
left a comment
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.
Good start. Case for list(measure.vars) is definitely missing.
| @@ -1,3 +1,4 @@ | |||
| if (getRversion() >= "2.15.1") utils::globalVariables(c("n_read")) | |||
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.
please explain this change!
| melt(DT, id.vars=patterns("[in]"), measure.vars=patterns("^f_", "^d_"), value.factor=TRUE) | ||
| # same as above, but provide list of columns directly by column names or indices | ||
| melt(DT, id.vars=1:2, measure.vars=list(3:4, c("d_1", "d_2")), value.factor=TRUE) | ||
| try(melt(DT, id.vars=1:2, measure.vars=list(3:4, c("d_1", "d_2")), value.factor=TRUE)) |
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.
why try?
Summary
This Pull Request addresses issue #6512 by making the error message in
melt.data.tablemore informative when a user provides column names inmeasure.varsthat do not exist in the dataset.Changes
measure.vars. It usessetdiff()to identify exactly which variables are missing from the data and reports them specifically.Impact
Instead of a generic:
Error: One or more values in 'measure.vars' is invalid.Users will now see:
Error: One or more values in 'measure.vars' is invalid; please fix by removing [z1]This change improves the developer experience by pinpointing the exact typo or missing column in the function call.
Closes #6512