title: How to find maximum value with date in each month in R?
body: <p>I am seeking answer to the question that has two parts. In part A: I would like to construct a data frame of the maximum value of total_precip (variable in my data frame) in each month with year, month, and day of its occurrence. In part B: I wanted to have another data frame where I can have the maximum cumulative total_precip for consecutive two day (i.e., sum of total_precip of two consecutive days higher than any other two days) in each month with dates and corresponding values. For example, if the sum of total_precip on Jan 10 and 11 is higher than any other two consecutive day of the month, the dates (year, month and corresponding days) along with its value will be stored in the data frame for each month of the year.</p>
  
  <p>Here is the code that I started to do part A but this gives me only the maximum value in each month without specifying which day that maximum value has occurred.</p>
  
  <pre><code>library(weathercan)
  library(tidyverse)
  DF = weather_dl(station_ids = 2925, start = "1990-01-01", end = "1995-12-31", interval = "day")[,c(11,12,13,14,32)]
  DF$month = as.numeric(DF$month)
  DF$day = as.numeric(DF$day)
  MaxValWithDate = DF %&gt;% group_by(year, month) %&gt;% summarise(MaxVal = max(total_precip))
  </code></pre>