Use draw_survfit() to draw fitted R survival objects. This interface accepts
portable records and does not require the survival package.
Usage
draw_survival(
data,
...,
group = NULL,
lower = NULL,
upper = NULL,
n_censor = NULL,
n_risk = NULL,
legend_position = "top",
legend_placement = "outside",
theme = NULL,
width = NULL,
height = NULL,
element_id = NULL,
filename = NULL
)Arguments
- data
Data frame or list: Curve records, or
curvesandriskframes.- ...
Additional named settings for
setup_SurvivalConfig().- group, lower, upper, n_censor, n_risk
Optional Character: Column bindings. When omitted, a column with the matching name is used if present. Explicit NULL disables that binding.
- 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.
- theme
Optional Theme: Chart theme.
- width, height
Optional Numeric or Character: Widget dimensions.
- element_id
Optional Character: HTML element identifier.
- filename
Optional Character: Static output path, currently SVG.
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.