Skip to contents

Draw precomputed survival estimates, without fitting a model in the renderer. Corresponds to LineSeriesOption in src/chart/line/LineSeries.ts and ScatterSeriesOption in src/chart/scatter/ScatterSeries.ts. ECharts docs: https://echarts.apache.org/en/option.html#series-line.step

Usage

SurvivalConfig(
  dat_path = NULL,
  title = NULL,
  origin = NULL,
  writer = NULL,
  legend_position = "top",
  legend_placement = "outside",
  time = "time",
  survival = "survival",
  group = NULL,
  lower = NULL,
  upper = NULL,
  n_censor = NULL,
  n_risk = NULL,
  show_ci = TRUE,
  show_censors = TRUE,
  show_median = FALSE,
  landmarks = NULL,
  risk_table = FALSE,
  ci_opacity = 0.15,
  line_width = 2,
  censor_size = 8,
  digits = 3L,
  palette = NULL,
  legend = TRUE,
  xlab = "Time",
  ylab = "Survival probability"
)

Arguments

dat_path

Optional Character: Path to the data, read at draw time. The serializable alternative to passing data to draw().

title

Optional Character: Chart title.

origin

Optional Named character {"user", "default", "derived"}: Where each value came from, one entry per settable property. Absent on an authored config; written by the interface that resolved it.

writer

Optional Named character: Which interface wrote the config, as name and version. Absent on an authored config.

legend_position

Character {"top", "bottom", "left", "right", "top-left", "top-right", "bottom-left", "bottom-right"}: Legend anchor. Top/bottom anchors use horizontal rows; left/right anchors use a vertical column. Corner anchors align within the top or bottom row.

legend_placement

Character {"outside", "inside"}: Relation to the plotting area. Outside placement reserves space for the complete legend; inside placement overlays the data. Neither setting adds a missing legend.

time

Character: Time column in the curve records.

survival

Character: Survival probability column.

group

Optional Character: Curve group column.

lower, upper

Optional Character: Pointwise confidence bound columns.

n_censor

Optional Character: Censor count column.

n_risk

Optional Character: Risk count column at recorded times.

show_ci

Logical: Draw available pointwise confidence bands.

show_censors

Logical: Draw censor ticks.

show_median

Logical: Draw median survival droplines when estimable.

landmarks

Optional Numeric vector: Finite times for survival labels.

risk_table

Logical: Draw supplied risk records beneath the curves.

ci_opacity

Numeric [0, 1]: Confidence band opacity.

line_width

Numeric: Curve stroke width in pixels.

censor_size

Numeric (0, Inf): Censor tick height in pixels.

digits

Integer: Decimal places for AUC labels and tooltip values.

palette

Optional Character: Group colors; unset uses the chart theme.

legend

Logical: Show group labels and AUC summaries.

xlab

Character: Horizontal axis label.

ylab

Character: Vertical axis label.

Value

A SurvivalConfig object.

Records and statistical semantics

Supply a curve data frame, or a list with curves and optional risk data frames. Each curve row contains time and survival probability, with optional group, pointwise lower/upper confidence bounds, censor counts, and risk counts. Include the initial time/probability explicitly: the renderer never invents an origin. Records are sorted within groups; times must be unique and finite, probabilities nonincreasing in [0, 1]. Curves are right-continuous and stop at their last recorded time. Missing confidence bounds produce gaps, not zeros. A censor tick represents one or more censored observations at that time; its tooltip retains the supplied count. Counts may be fractional for weights. Median survival is the first crossing of 0.5; a plateau at 0.5 uses its midpoint, including the last follow-up time if the plateau is terminal. Comparisons to 0.5 use tolerance sqrt(.Machine$double.eps), as in survival. Landmarks outside a group's observed time range are omitted without extrapolation. Display precision never rounds plotted coordinates.

Risk records have fixed columns time, group, and n_risk, and state the risk count immediately before the specified time. They must cover the same unique times in each group. Unknown counts use NA and display as NA. The renderer does not interpolate or infer risk sets from the curves. All layers belonging to a group share its legend toggle, including risk rows.

Examples

cfg <- setup_SurvivalConfig()
draw(cfg, data = data.frame(time = c(0, 1, 2), survival = c(1, .8, .5)))