as_surv() turns an event_time() vector into the Surv() response the models take. The type
of the response depends on the status codes present, with missing elements ignored:
Arguments
- x
An
event_time()vector.- ...
Unused.
Value
A Surv() response the length of x.
Details
Only events and right-censoring: a right-censored response, with status
1for an event.Only events and left-censoring: a left-censored response.
Anything else: an interval-censored response, with status
0for right-censored,1for an event,2for left-censored, and3for interval-censored.
Missing elements stay missing, and a vector of length zero gives an empty right-censored
response. A Surv() response is returned as it is.
Examples
as_surv(event_time(time = c(7, 5, 3), status = c("e", "r", "r")))
#> <Surv[3]: right>
#> [1] 7 5+ 3+
as_surv(event_time(time = c(7, 2), status = c("e", "i"), time_max = c(NA, 4)))
#> <Surv[2]: interval>
#> [1] 7 [2, 4]