I have a R data frame df as below
ID <- c(1,2,1,3,3,3)
Time <- c("7:30","10:30","11:00","4:00","8:00","8:00")
sub_event <- c("TLIF","ALIF","ALIF","ALIF","TLIF","LAMI")
df <- data.frame(ID,Time,sub_event)
I am interested in the sequence of event by ID. e.g. ID 1, has 2 events at 7:30 and 10:30, and they should be seq 1 and 2 respectively for ID 1. The sequence is the order of events for an ID. Also an event is broken into sub-events and rowid is not useful. I am looking for an output as below
ID Time seq
1 1 7:30 1
2 2 10:30 1
3 1 11:00 2
4 3 4:00 1
5 3 8:00 2