surv_converter: convert censored times

Description Usage Arguments Value Functions Examples

View source: R/censored-formats.R

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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
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

Examples

1
2
3
4
5
6
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/dm documentation built on Jan. 18, 2022, 9:50 a.m.