I have a group of times that I have already converted to time intervals, and I would like to assign an unique ID for every unique time intervals. The data frame y looks something like:
start end
01:00:00 05:00:00
13:00:00 17:00:00
12:00:00 16:00:00
01:00:00 05:00:00
13:00:00 17:00:00
And I used the following code to create a time interval:
y$interval = data.frame(interval=paste(start,end))
and the results look like
start end interval
01:00:00 05:00:00 01:00:00 05:00:00
13:00:00 17:00:00 13:00:00 17:00:00
12:00:00 16:00:00 12:00:00 16:00:00
01:00:00 05:00:00 01:00:00 05:00:00
13:00:00 17:00:00 13:00:00 17:00:00
I would now like to create a new column in Y that assigns an unique ID to every unique time interval:
start end interval ID
01:00:00 05:00:00 01:00:00 05:00:00 1
13:00:00 17:00:00 13:00:00 17:00:00 2
12:00:00 16:00:00 12:00:00 16:00:00 3
01:00:00 05:00:00 01:00:00 05:00:00 1
13:00:00 17:00:00 13:00:00 17:00:00 2
I have tried using dplyr's group_indice:
y$id = group_indices(y$interval)
but it assigns ID number 1 to every interval. What should I do?
Thanks so much!