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
Implement a safer alternative to funs() #3433
Comments
When users supplies functions I think we can check if they are identical to base/stats variants and in that case create calls so the hybrid evaluator can pick them up. |
I think there would be no new verbs needed. We'd just accept functions and lists (maybe we do already). |
And formulas, which I don't think we do currently. |
We need to prioritise this for the next release because the current behaviour are so inconsistent (particularly across funs and any_vars, and then compared to purrr) |
As part of this we should consider the argument names to filter_if and filter_at, because the current args are confusing |
If we switch to That way Another approach would be modify |
Would it work if we translate e.g. We could implement |
@romainfrancois will make a function that returns a character vector of the hybridised function so we can compare individually for equality. |
Lets calve out hybridising anonymous functions created by Then I think this issue can be resolved with three steps:
|
#3888 implements the second • library(tidyverse)
trace(summarise_at, exit = quote(print(funs)))
#> Tracing function "summarise_at" in package "dplyr"
#> [1] "summarise_at"
fns <- map(list(m1 = mean, m2 = ~mean(.)), rlang::as_function)
summarise_at(mtcars, vars(cyl), fns)
#> Tracing summarise_at(mtcars, vars(cyl), fns) on exit
#> $m1
#> <quosure>
#> expr: ^<function(x, ...) UseMethod("mean")>(cyl)
#> env: global
#>
#> $m2
#> <quosure>
#> expr: ^<S3: rlang_lambda_function>(cyl)
#> env: global
#> m1 m2
#> 1 6.1875 6.1875 Created on 2018-10-10 by the reprex package (v0.2.1.9000) |
Warn if |
This is essentially done. To be finalized in #4125 |
For more info, see tidyverse/dplyr/issues/3433
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/ |
Using anonymous functions or shortcuts from purrr. From discussions in #3094 and #3368.
Also fixes scoped functions for
tbl_lazy
, see #3594:Easiest to do with new verbs. I think we can still continue supporting
funs()
for some time.Need to keep in mind updating and improving the documentation.
The text was updated successfully, but these errors were encountered: