| grouped_dt {dtplyr} | R Documentation |
The easiest way to create a grouped data table is to call the group_by
method on a data table or tbl: this will take care of capturing
the unevalated expressions for you.
grouped_dt(data, vars, copy = TRUE) is.grouped_dt(x)
data |
a tbl or data frame. |
vars |
a list of quoted variables. |
copy |
If |
x |
an object to check |
library(dplyr, warn.conflicts = FALSE)
if (require("nycflights13")) {
flights_dt <- tbl_dt(flights)
group_size(group_by(flights_dt, year, month, day))
group_size(group_by(flights_dt, dest))
monthly <- group_by(flights_dt, month)
summarise(monthly, n = n(), delay = mean(arr_delay))
}