if censor_time < time, event is change to 0, otherwise not changed
Details
if censor_time < time, time is changed to censor_time, otherwise no change
Be careful and do not overwrite the time variable with the censor time variable to not loose track of the events
Examples
if (FALSE) { # { FALSE }
# Typical workflow in a simulation of survival time.
# Simulate time to event (sim_t_event)
# and simulates the time to lost to follow up (tim_t_ltof)
# the simulation time frame is 1, so everything after 1 is censored
require(dplyr)
data.frame(
sim_t_event = c(0.5,0.6,1,10,20),
sim_t_ltof = c(2,0.5,2,2,0.8)
) |>
mutate(sevent = censor_event(1,sim_t_event,sim_event=1)) |>
mutate(stime = censor_time(1,sim_t_event)) |>
mutate(event = censor_event(sim_t_ltof, stime, sevent)) |>
mutate(timeto = censor_time(sim_t_ltof, stime))
}