I am creating my dataset to carry out a survival analysis. I have these variables:
CASE_ID, i_birthdate_c, i_deathdate_c, difftime_c,  event1, enddate.
- Case_id= unique ID
- birthdate= subject, enters observation
- deathdate= when they died
- difftime_cis the time from birth to death
- event1= censoring variable indicating death has or has not occurred
- enddate= when all subjects will be censored if the event has not occurred.
I am trying to calculate the time from i_birthdate_c to enddate (12/31/2013). I want this value to be finally populated in my difftime_c variable if the event1 = 0. As it stands, I have the time from  i_birthdate_c to i_deathdate_c for when event1 = 1.
What would be the most efficient way of accomplishing this in R with the existing code I have below? I keep striking out with my if statements.
Model:
newdata$difftime_c <- difftime(newdata$deathdate_c,newdata$birthdate_c,units="weeks")
 
    