-
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
Informative error message when "primary pipe input" is missing #4127
Comments
Unfortunately, I don't think there is much we can do here, as the error happens before S3 dispatch, i.e. the first argument has to be evaluated before the |
We can do a mutate <- function(.data, ...) {
quo <- enquo(.data)
tryCatch(
force(.data),
error = function(e) {
abort(paste0("`.data` must be a data source. ", conditionMessage(e)))
}
)
UseMethod("mutate")
} This doesn't look very helpful right now, perhaps if we had a dplyr::mutate(!!col := !!col * 10)
#> Error: `.data` must be a data source. could not find function ":="
#> Backtrace:
#> █
#> 1. └─dplyr::mutate(`:=`(!!col, !!col * 10))
#> 2. └─base::tryCatch(...) /home/kirill/git/R/dplyr/R/manip.r:442:2
#> 3. └─base:::tryCatchList(expr, classes, parentenv, handlers)
#> 4. └─base:::tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 5. └─value[[3L]](cond) Created on 2019-01-29 by the reprex package (v0.2.1.9000) |
We'd have to do that for every generic then. Sounds painful. |
The cost-benefit tradeoff does not favour adding a |
We do this in |
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/ |
Just a really minor thing I noticed (and possibly this is rather a
magrittr
issue?):While refactoring a function, I accidentally dropped the initial
df %>%
part of a pipe that used:=
.But before I realized this, I was puzzled for a couple minutes by the error below as it didn't suggest the reason was the missing
df %>%
but not being able to find function:=
.Maybe one could come up with error messages along the lines of
primary pipe input 'x' missing
?The text was updated successfully, but these errors were encountered: