Useful for converting a v_rcensored
object into the form that is
expected as an input to various routines in the survival package. More
concretely, this function returns an object with the same form as is returned
by calling survival::Surv()
.
as_Surv(x, censor_as_event = FALSE, multiple_endpoint = FALSE)
a v_rcensored
object.
an indicator for whether to treat censoring as the
event of interest (such as when estimating censoring probabilities). When
TRUE
, all outcomes are treated as a single censoring event and
censoring events as a single outcome. Defaults to FALSE
.
an indicator for whether to treat the outcomes as
multiple endpoint data. Otherwise all outcomes are treated as being the
same event type. Defaults to FALSE
.
# Example censoring and outcome times data
ctime <- v_continuous_nonneg(c(5, 6, 10, 1, Inf, 19), internal_name = "censoring")
otime <- v_continuous_nonneg(c(2, 6, 11, 12, Inf, 25), internal_name = "outcomes")
# Construct a `v_censored` value
v <- v_rcensored(
outcomes = list(ctime),
censors = list(otime),
end_time = 15,
)
# Convert to a 'survival' package right-censored data representation
as_Surv(v)
#> [1] 2+ 6 10 1 15+ 15+