dates_of_records <- sample(seq(as.Date("2015-01-01"), as.Date("2021-12-31"), 7), 10)
# whether there is any 3 records at least 30 days apart within 2 years
if_date(dates_of_records, n = 3, apart = 30, within = 365 * 2)
# specified either apart or within or both
if_date(dates_of_records, n = 2, within = 365)
Run the code above in your browser using DataLab