I have a dataset with irregular dates column. I want to create an index column. Index ID (e.g. 1) is same for three dissimilar consecutive dates then changes (e.g. to 2) for next three dissimilar consecutive dates and so on. Here is a sample of dates and how the desired column shall look like:
structure(list(Date = c(42370, 42371, 42371, 42371, 42372, 42372,
42375, 42375, 42375, 42377, 42377, 42383, 42383, 42385, 42386,
42386, 42386, 42393, 42393, 42394, 42394, 42395, 42398, 42398,
42398, 42398), Index = c(1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
2, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4)), .Names = c("Date",
"Index"), row.names = c(NA, 26L), class = "data.frame")