Last chance! 50% off unlimited learning
Sale ends in
Function takes a survfit
object as an argument, and provides a
formatted summary of the results
# S3 method for survfit
tbl_survival(x, times = NULL, probs = NULL,
label = ifelse(is.null(probs), "{time}", "{prob*100}%"),
level_label = "{level}, N = {n}", header_label = NULL,
header_estimate = NULL, failure = FALSE, missing = "-",
estimate_fun = NULL, ...)
A tbl_survival
object
The level_label
is used to modify the stratum labels. The default is
level_label = "{level}, N = {n}"
. The quantities in the curly
brackets evaluate to stratum-specific values. For example, in the trial
data set, there is a column called trt
with levels 'Drug' and 'Placebo'.
In this example, {level}
would evaluate to either 'Drug' or 'Placebo'
depending on the stratum. Other quantities available to print are:
{level}
level of the stratification variable
{level_label}
label of level for the stratification variable
{n}
number of observations, or number within stratum
{n.event.tot}
total number of events (total across stratum, if applicable)
{n.event.strata}
total number of events within stratum, if applicable
{strata}
raw stratum specification from survfit
object
Example 1
Example 2
Other tbl_survival tools: inline_text.tbl_survival
,
modify_header
# NOT RUN {
library(survival)
fit1 <- survfit(Surv(ttdeath, death) ~ trt, trial)
tbl_strata_ex1 <-
tbl_survival(fit1,
times = c(12, 24),
label = "{time} Months"
)
fit2 <- survfit(Surv(ttdeath, death) ~ 1, trial)
tbl_nostrata_ex2 <-
tbl_survival(fit2,
probs = c(0.1, 0.2),
header_estimate = "**Months**"
)
# }
Run the code above in your browser using DataLab