Closed huisaddison closed 3 years ago
It's not currently on the roadmap because I don't think group_modify()
is needed any more (see https://www.tidyverse.org/blog/2020/03/dplyr-1-0-0-summarise/ for details)
@hadley, I disagree. goup_modify is still needed because the following is working with group_modify but not working with summarise no matter whether the tilde ~ is included or not:
iris %>% group_by(Species) %>% summarize(~broom::tidy(lm(Petal.Length ~ Sepal.Length, data = .x))) Error: Problem with
summarise()
input..1
. i..1 = ~broom::tidy(lm(Petal.Length ~ Sepal.Length, data = .x))
. x..1
must be a vector, not aformula
object. i The error occurred in group 1: Species = setosa. Runrlang::last_error()
to see where the error occurred.
@rxhu, it works for me without the tilde (the first one that is), if you also remove data = .x
:
library(dplyr)
iris %>% group_by(Species) %>% summarize(broom::tidy(lm(Petal.Length ~ Sepal.Length)))
... of course, the warning you get is not exactly encouraging:
Returning more (or less) than 1 row per `summarise()` group was deprecated in
dplyr 1.1.0.
ℹ Please use `reframe()` instead.
I haven't been able to get Update: after doing my homework,reframe
to work yet, like, at all — multidplyr or no. 🤷
library(dplyr)
iris %>% reframe(.by = Species, broom::tidy(lm(Petal.Length ~ Sepal.Length)))
Getting back to the issue at hand, so to speak. Out of the group_modify()
, summarise()
and reframe()
approaches, only the one with summarise()
appears to currently be compatible with multidplyr
(obsolescence warning notwithstanding):
library(dplyr)
library(multidplyr)
cluster <- new_cluster(2)
iris %>% group_by(Species) %>% partition(cluster) %>% summarize(broom::tidy(lm(Petal.Length ~ Sepal.Length)))
The other two approaches give off an error message like
Error in UseMethod("reframe") :
no applicable method for 'reframe' applied to an object of class "multidplyr_party_df"
As far as the latter is concerned, I took the liberty to open #143 afresh.
In a previous comment for issue #51, plans for implementation of group_modify() and group_map() were mentioned. However, the current version 0.0.0.9 does not appear to have it implemented.
(If this is an inappropriate venue to discuss planned feature development, please close this issue, though I would be interested to know where in the roadmap group_modify falls).
Reprex: