For example, using the airquality data, I want to calculate the maximum temperature for each month. Then keep the day on which this maximum temperature occurred.
library(dplyr)
# Maximum temperature per month
airqualitymax <- airquality %>% 
    group_by(Month) %>% 
    summarise(maxtemp = max(Temp))
# Day of the month on which the max occured
airquality %>% 
    left_join(airqualitymax, by = "Month") %>%
    filter(Temp == maxtemp) 
Now it appears that the day is not unique, but suppose it was unique, Is there a way to select the day on which the maximum occurs in the summarise() directly?
 
    