Learn R Programming

bayesics (version 2.0.2)

Surv: Create a Survival Object

Description

Create a survival object, usually used as a response variable in a model formula. Argument matching is special for this function, see Details under Surv. This is a restricted wrapper around Surv and currently supports only right-censored data.

Usage

Surv(...)

Value

An object of class "Surv".

Arguments

...

arguments to be passed into survival::Surv. Currently, the input must be of the form Surv(time,event) for right censored data.

References

Therneau T (2024). A Package for Survival Analysis in R. R package version 3.8-3, https://CRAN.R-project.org/package=survival.

Examples

Run this code
# \donttest{
set.seed(2025)
N = 300
test_data = 
  data.frame(outcome = 
               rweibull(N,2,5))
test_data$observed = 
  ifelse(test_data$outcome >= 7, 0, 1)
test_data$outcome =
  ifelse(dplyr::near(test_data$observed,1), test_data$outcome, 7)
Surv(test_data$outcome,
     test_data$observed)
# }

Run the code above in your browser using DataLab