origin, dest) |> summarise( 件数 = n(), 平均 = mean(air_time, na.rm = TRUE), 中央値 = median(air_time, na.rm = TRUE), .groups = "drop" ) } # dtplyrでの処理を関数化 f_dtplyr <- function(){ dat |> lazy_dt() |> group_by(month, carrier, origin, dest) |> summarise( 件数 = n(), 平均 = mean(air_time, na.rm = TRUE), 中央値 = median(air_time, na.rm = TRUE), .groups = "drop" ) |> as_tibble() }