# A dataframe of times
set.seed(563248)
dd <- data.frame( id = 1:30,
doN = round(runif(30,-30, 0),1),
doE = round(runif(30, 0,20),1),
doX = round(runif(30, 50,60),1),
doD = round(runif(30, 50,60),1),
# these are the event times
doA = c(NA,21,NA,27,35,NA,52, 5,43,80,
NA,22,56,28,53,NA,51, 5,43,80,
NA,23,NA,33,51,NA,55, 5,43,80),
doB = c(NA,20,NA,53,27,NA, 5,52,34,83,
NA,20,23,37,35,NA,52, 8,33,NA,
25,NA,37,40,NA,NA,15,23,36,61) )
# set up a Lexis object with time from entry to death/exit
Lx <- Lexis( entry = list(time=doE,
age=doE-doN),
exit = list(time=pmin(doX,doD)),
exit.status = factor(doD
Run the code above in your browser using DataLab