I am trying to create a new column in my dataframe, and assign numbers in this new column as per dates of a particular surgery/procedure chronologically. So, for example, ID 234 had 3 procedures, 1st in Apr 2002, 2nd in May 2002 and 3rd in June 2003. I want to create this new column so it would generate number 1 for the first procedure in Apr 2002, number 2 for the second procedure in May 2002 and number 3 for third procedure in June 2003. Would appreciate any help. TIA.
I tried using ifelse() but I couldn't assign numbers as per chronology.