Skip to contents

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:

Usage

as_surv(x, ...)

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 1 for an event.

  • Only events and left-censoring: a left-censored response.

  • Anything else: an interval-censored response, with status 0 for right-censored, 1 for an event, 2 for left-censored, and 3 for 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]