surv_converter: convert censored times

View source: R/censored-formats.R

surv_converterR Documentation

convert censored times

Description

censored times might already be of the 'Surv' class, or where the 'time' and 'event' components of such a class is stored separately, either way this is a function to transition between these two formats

Usage

surv_converter(
  data,
  id = NULL,
  toSurv = NULL,
  .fix = c(time = "t.", event = "ev."),
  suffix = TRUE
)

surv_pair2Surv(
  data,
  id = NULL,
  .fix = c(time = "t.", event = "ev."),
  suffix = TRUE
)

Surv2surv_pair(
  data,
  id = NULL,
  .fix = c(time = "t.", event = "ev."),
  suffix = TRUE
)

Arguments

data

the data, a data frame or some such object

id

is there an identifiction variable that should remain in the data set

toSurv

logical; resulting variables to be of class 'Surv'?

.fix

named vector of pre- or suffix that identifies the 'time' and 'event'-variables (names must contain "time" and "event")

suffix

is .fix a suffix?

Value

a data frame

Functions

  • surv_pair2Surv(): transition from separate variables to class 'Surv'

  • Surv2surv_pair(): transition from class 'Surv' to separate variables

Examples

df <- data.frame(
       persnr = sprintf("id%s", 1:10),
       t.arg = rexp(10, 1/50),
       ev.arg = rbinom(10, 1, 0.7)
)
surv_converter(df, id = "persnr")

renlund/datma documentation built on June 2, 2025, 5:12 a.m.