# Libraries
library(dplyr)
# Max value in each month
m4_daily %>%
group_by(id) %>%
filter_period(.period = "1 month", value == max(value))
# First date each month
m4_daily %>%
group_by(id) %>%
filter_period(.period = "1 month", date == first(date))
# All observations that are greater than a monthly average
m4_daily %>%
group_by(id) %>%
filter_period(.period = "1 month", value > mean(value))
Run the code above in your browser using DataLab