Closed
Description
I have some code which seems to have broken since group_map()
became group_modify()
. Converting to group_modify()
only partially resolves this as my function also requires additional arguments. Under the old group_map()
my function received args passed in ...
, but I get an error for the same function under the new group_modify()
.
The docs indicate I should be able to do this:
... Additional arguments passed on to .f
Is this a regression, or am I doing something wrong?
# dplyr_0.8.3
library(tidyverse)
m <- function(x, y, a, b) {
tibble(z = z)
}
mtcars %>%
group_by(cyl) %>%
group_modify(m, 1, 2) %>%
ungroup
Error in (function (.x, .y) : unused arguments (1, 2)
Metadata
Metadata
Assignees
Labels
No labels
Activity
cderv commentedon Jul 30, 2019
I think there is indeed an issue in
group_modify
dplyr/R/group_map.R
Lines 153 to 166 in ec09492
the
...
are passed to a newfun
of two arguments.x
and.y
but then a re-pass ingroup_map
applied onfun
and this is where the error comes from becausefun
does not expect more than its two arguments.I don't think the dots need to be passed in the second case and it should be
Allow group_modify() to work with ... args (Fix tidyverse#4509)
billdenney commentedon Nov 16, 2019
I experienced the same issue just now. @cderv, I came up with the same fix before coming to the issue, so I included both of our names in the NEWS file.
cderv commentedon Nov 17, 2019
Oh thanks ! I forgot about that one and forgot to do a PR 🤦♂
Thank @billdenney ! it was not necessary to mention me in NEWS but I appreciate it. 👍
Allow group_modify() to work with ... args (Fix #4509) (#4620)