-
Notifications
You must be signed in to change notification settings - Fork 58
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
Plans on adding group_map/group_modify/group_walk support? #108
Comments
I think library(data.table)
library(dplyr, warn.conflicts = FALSE)
dt <- data.table(g = c(1, 1, 2), x = 1:3, y = 2:4, z = 3:5)
myfun <- function(df, key) {
data.frame(xy = df$x + df$y, yz = df$y + df$z)
}
dt %>%
as_tibble() %>%
group_by(g) %>%
group_modify(myfun)
#> # A tibble: 3 x 3
#> # Groups: g [2]
#> g xy yz
#> <dbl> <int> <int>
#> 1 1 3 5
#> 2 1 5 7
#> 3 2 7 9
dt[, as.data.table(myfun(.SD)), key = g]
#> g xy yz
#> 1: 1 3 5
#> 2: 1 5 7
#> 3: 2 7 9 Created on 2019-10-04 by the reprex package (v0.3.0) |
Implementing this will require a |
Need #110 before I implement group_split.dtplyr_step <- function(x, ...) {
warn("Forcing evaluation of lazy data table in group_split()")
group_split(collect(x), ...)
} |
That approach doesn't work because Once that issue is fixed, I think #' @export
#' @importFrom dplyr group_split
group_map.dtplyr_step <- function(.tbl, .f, ..., keep = FALSE) {
dt <- as.data.table(.tbl)
dt[, list(list(.f(.SD, .BY, ...))), by = .tbl$groups]$V1
} |
Love dtplyr! I am using the newest version (lazy evaluation) as often as possible.
Sadly there is no support for group_map, group_modify, group_walk functionality.
Are there any plans on adding them in the future?
Here is a failing example:
Also a working example with native data.table and dplyr:
The text was updated successfully, but these errors were encountered: