if (require("data.table") && 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))
}
Run the code above in your browser using DataLab