Have a structure long data set. Where unique IDs enter a time span of 2-3 weeks. The data is is in long format. The unique IDs enter the data set at a different time span. I would like to create a unique ID per time span.
df <- data.frame(id = rep(c("1","2","3","1"), each=2),
counter=c(1,2,1,2,1,2,1,2),
date_t=rep(seq(c(ISOdate(2021,3,20,9,7)), by = "day", length.out = 2),times=4),
task=c("A","B","A","B","A","B","A","B"), stringsAsFactors=FALSE)
This the expected output: enter image description here