Closed davidbmitchell closed 6 years ago
Forgot to add the traceback:
Error in mutate_impl(.data, dots) :
Evaluation error: $ operator is invalid for atomic vectors.
10. stop(structure(list(message = "Evaluation error: $ operator is invalid for atomic vectors.", call = mutate_impl(.data, dots),
cppstack = NULL), .Names = c("message", "call", "cppstack"), class = c("Rcpp::eval_error", "C++Error",
"error", "condition")))
9. mutate_impl(.data, dots)
8. mutate_.tbl_df(x$data, raa.pitch = ~predict(mod.pitch, newdata = x$data[, c("venueId", "throws", "stand")]) - delta.pitch)
7. mutate_(x$data, raa.pitch = ~predict(mod.pitch, newdata = x$data[, c("venueId", "throws", "stand")]) - delta.pitch) at makeWAR.R#152
6. makeWAR.GameDayPlays_Fielding(x, models, verbose, low.memory, step, ...) at makeWAR.R#76
5. makeWAR(x, models, verbose, low.memory, step, ...) at makeWAR.R#127
4. makeWAR.GameDayPlays_Runs(out, models, verbose, low.memory, step, ...) at makeWAR.R#76
3. makeWAR(out, models, verbose, low.memory, step, ...) at makeWAR.R#101
2. makeWAR.GameDayPlays(May) at makeWAR.R#76
1. makeWAR(May)
Hmm...OK, I will investigate. Or I would be happy to field a pull request if you find the problem.
I believe dplyr is breaking some functions because of the new approach to Non-Standard Evaluation they are using called "tidyeval". I'm still trying to wrap my head around it. I made a change on Line 152 of makeWAR.R
. I wrapped mutate
in quo()
, removed the underscore and the tilde in front of predict
. This fixed the error, but I don't know 100% why.
x$data <- quo(mutate(x$data, raa.pitch = predict(mod.pitch, newdata = x$data[, c("venueId", "throws", "stand")]) - delta.pitch))
With that being said, it threw another error later on Line 169
mod.off <- getModelOffense(select_(x$data, "delta", "venueId", "throws", "stand"),
models[["offense"]], verbose)
Error in UseMethod("select_") :
no applicable method for 'select_' applied to an object of class "c('quosure', 'formula')"
I just need to learn more about "tidyeval" to figure out why some functions are running fine and others are throwing errors.
I stumbled across this today when I was playing around with openWAR at work. In short, I created a new instance on https://r-brain.io/ and installed the newest dplyr, 0.7.1. After a while I came to the conclusion it had to be something that changed in dplyr.
So I came home, updated dplyr on my computer, previously version 0.5.0, and sure enough, the error happened again.
I just ran this code of my computer at home, which is the same as I ran today at work.
Going through the dplyr repository it looks like there have been some major changes starting in April. I need to dig into this more to figure out what needs to be changed, and if there are any other functions that could be affected.