group_by
method on a data table or tbl: this will take care of capturing
the unevalated expressions for you.grouped_dt(data, vars)is.grouped_dt(x)
if (require("data.table")) {
data("hflights", package = "hflights")
hflights_dt <- tbl_dt(hflights)
group_size(group_by(hflights_dt, Year, Month, DayofMonth))
group_size(group_by(hflights_dt, Dest))
monthly <- group_by(hflights_dt, Month)
summarise(monthly, n = n(), delay = mean(ArrDelay))
}
Run the code above in your browser using DataLab