Summarizing logical vectors (3)

flights |> 
  summarize(
    proportion_delayed = mean(dep_delay <= 60, na.rm = TRUE),
    count_long_delay = sum(arr_delay >= 300, na.rm = TRUE),
    .by = c(year, month, day)
  )
## # A tibble: 365 × 5
##     year month   day proportion_delayed count_long_delay
##    <int> <int> <int>              <dbl>            <int>
##  1  2013     1     1              0.939                3
##  2  2013     1     2              0.914                3
##  3  2013     1     3              0.941                0
##  4  2013     1     4              0.953                0
##  5  2013     1     5              0.964                1
##  6  2013     1     6              0.959                0
##  7  2013     1     7              0.956                1
##  8  2013     1     8              0.975                0
##  9  2013     1     9              0.986                1
## 10  2013     1    10              0.977                2
## # ℹ 355 more rows