I have a data frame with a ID and date of diagnosis and date of procedure . There are many date of diagnosis and many procedure dates for the same ID. I want to create a new column called next date using the ID and the diagnosis date.
for example my data looks like this
ID Diagnosis date Procedure date Next Date
1 2008-03-01 2009-04-05 2009-05-06
1 2009-05-06 2008-03-02 2010-08-09
1 2010-08-09 2015-08-09 2010-08-09
1 2010-08-09 2013-07-08 2010-08-09
2 2005-06-09 2009-09-02 2009-09-08
2 2009-09-08 2010-06-05 2009-09-08
I want to get a separate column called Next Date based on Diagnosis date and sort the procedure date according to that. Because Procedure date should be after the diagnosis date.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…