Skip to contents

[Stable]

Convert the survival fit data into a data frame designed for plotting within g_km.

[Stable]

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.

Usage

h_data_plot(fit_km, armval = "All", max_time = NULL)

Arguments

fit_km

(survfit)
result of survival::survfit().

armval

(string)
used as strata name when treatment arm variable only has one level. Default is "All".

max_time

(numeric)
maximum value to show on X axis. Only data values less than or up to to this threshold value will be plotted.(NULL for default)

Examples

if (FALSE) {
library(scda)
library(dplyr)
library(survival)

# Test with multiple arms
synthetic_cdisc_data("latest")$adtte %>%
  filter(PARAMCD == "OS") %>%
  survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>%
  h_data_plot()

# Test with single arm
synthetic_cdisc_data("latest")$adtte %>%
  filter(PARAMCD == "OS", ARMCD == "ARM B") %>%
  survfit(form = Surv(AVAL, 1 - CNSR) ~ ARMCD, data = .) %>%
  h_data_plot(armval = "ARM B")
}