h_data_plot | R Documentation |
Convert the survival fit data into a data frame designed for plotting
within g_km
.
This starts from the broom::tidy()
result, and then:
Post-processes the strata
column into a factor.
Extends each stratum by an additional first row with time 0 and probability 1 so that downstream plot lines start at those coordinates.
Adds a censor
column.
Filters the rows before max_time
.
h_data_plot(fit_km, armval = "All", max_time = NULL)
fit_km |
( |
armval |
( |
max_time |
( |
A tibble
with columns time
, n.risk
, n.event
, n.censor
, estimate
, std.error
, conf.high
,
conf.low
, strata
, and censor
.
library(dplyr)
library(survival)
# Test with multiple arms
tern_ex_adtte %>%
filter(PARAMCD == "OS") %>%
survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>%
h_data_plot()
# Test with single arm
tern_ex_adtte %>%
filter(PARAMCD == "OS", ARMCD == "ARM B") %>%
survfit(formula = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>%
h_data_plot(armval = "ARM B")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.