-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior
Milestone
Description
Hi, I've noticed that do on grouped data.table doesn't send all columns into function.
library(nycflights13)
library(dplyr)
g <- function(x) {
browser()
}
flights %>%
data.table() %>%
select(origin, flight, distance, dep_delay, hour, minute) %>%
group_by(flight, distance, dep_delay) %>%
do(
data.frame(g(.))
)
Inside g() you'll see
Source: local data table [1 x 3]
Groups: flight, distance, dep_delay
origin hour minute
1 EWR 14 0
As I believe the goal is to have unified results for all sources, hence function should receive all columns.
The solutions might be (based on http://stackoverflow.com/questions/26636402/how-i-can-get-the-value-of-grouping-column-inside-user-define-function-in-data-t/26641743#26641743) replace in do.grouped_dt
call <- substitute(dt[, cols, by = vars], list(cols = cols))
by
call <- substitute(dt[, cols, by = vars, .SDcols = names(dt)], list(cols = cols))
or add names to dt_env.
Metadata
Metadata
Assignees
Labels
bugan unexpected problem or unintended behavioran unexpected problem or unintended behavior