View source: R/censored-formats.R
surv_converter | R Documentation |
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
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
)
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? |
a data frame
surv_pair2Surv()
: transition from separate variables to class 'Surv'
Surv2surv_pair()
: transition from class 'Surv' to separate variables
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.