-
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
do() does not work with inlined function definitions #574
Comments
@holgerbrandl you should really enclose anonymous functions in parentheses. possibly related: tidyverse/magrittr#12 |
The problem is that The whole point of the . pronoun is to avoid defining anonymous functions. Maybe what you're asking for is for this to work? iris %>% group_by(Species) %>% do(identity) |
@hadley: Indeed that's what I would love to do! It's the equivalent of
@KyKuo: I just call them right away with Personally, I think that anonymous functions should be possible because when using
compared to
|
@holgerbrandl but you don't need an anonymous function to do that: data %>% mutate(...) %>% group_by(...) %>% do({
... really fancy stuff ...
}) %>% select ... |
@hadley That's pretty cool and indeed makes anonymous function unnecessary here. Thank you very much. |
Using todays github-snapshot this works
but the the same logic with the method definition being inlined fails without any obvious reason
It looks like it worked a while ago (see http://stackoverflow.com/a/22182914/590437)
Adding another set of round brackets around the function definition seems to solve the problem, but I doubt that many users will guess this:
For improved readability it would be great if
(.)
could be optionally left out. Then function object would be passed as argument todo
which would need to invoke it with the the group table as sole argument. This was how it worked beautifully withddply
.The text was updated successfully, but these errors were encountered: