Hello R user, I have a data set from a longitudinal study ( sample below) where subjects are followed over time. Second column (status) contains info about if subject is dead or still in the study and third column is time measured in the week. Here is what I need: if status is not dead or unknown take the last week, if status is dead or unknown I need to have corresponding week.
Desired resulst: 1 no 7 2 yes 5 3 Unknown 4 Sample data id status week 1 no 1 1 no 2 1 no 3 1 no 4 1 no 5 1 no 6 1 no 7 2 no 1 2 no 2 2 no 3 2 no 4 2 yes 5 2 yes 6 2 na 7 2 na 8 2 na 9 3 no 1 3 no 2 3 no 3 3 Unknown 4 3 unknown 5 3 na 6 3 na 7 3 na 8 Any suggestion is much appreciated! Thank you. Bibek ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.