Thanks for the reply, I'm actually looking to create the groups based on all dates that fall within 28 days after the start date. This could either be a number (i.e. 1, 2, 3) or the minimum date of that grouping. The expected output would look like this:
tibble::tribble(
~id, ~date, ~date_group
1,'01/01/2011','01/01/2011',
2,'01/05/2011','01/01/2011',
3,'01/10/2011','01/01/2011',
4,'02/01/2011','02/01/2011',
5,'02/10/2011','02/01/2011',
6,'02/11/2011','02/01/2011',
7,'02/19/2011','02/01/2011',
8,'03/01/2011','02/01/2011',
9,'03/02/2011','03/02/2011',
10,'03/03/2011','03/02/2011',
11,'03/04/2011','03/02/2011',
12,'04/29/2011','04/29/2011',
13,'05/01/2011','04/29/2011',
14,'05/02/2011','04/29/2011',
15,'05/29/2011','05/29/2011',
16,'05/30/2011','05/29/2011',
17,'06/01/2011','05/29/2011',
18,'06/02/2011','05/29/2011',
19,'06/03/2011','05/29/2011',
20,'06/10/2011','05/29/2011'
)
We start at 01/01/2011 + 28 days would group all dates between 01/01/2011 and 01/29/2011, then we go to 02/01/2011 + 28 days and group all the dates in that range (02/01/2011 to 03/01/2011), then 03/02/2011 + 28 days and so on. Basically starting with the minimum date + 28 days and re-indexing on the next minimum date that does not fall in the prior 28 day period.