| er_tte_add_summary | R Documentation |
Adds the summary layer to a TTE plot: a corner-placed text/label annotation, summarising one or more aspects of the plot or the data.
er_tte_add_summary(
object,
model = NULL,
style = NULL,
keep_strata = NULL,
conf_level = 0.95,
summary_args = list(),
...
)
object |
Partially constructed plot (has S3 class |
model |
A fitted time-to-event model implementing |
style |
Style used to produce the summary layer annotation. Can
either be a string corresponding to one of the registered style labels
(e.g., |
keep_strata |
Logical; whether this layer should use stratification.
Defaults to |
conf_level |
Confidence level forwarded to |
summary_args |
A named list of additional arguments forwarded to
|
... |
Additional named arguments forwarded to the |
The annotation is placed in whichever corner of the panel is
currently furthest from the plotted survival curve(s), computed the
same way er_plot_add_summary()'s corner-placed annotation avoids
the raw data – see er_style_tte_summary_logrank().
The default log-rank builder draws nothing on an unstratified object,
or one with only 1 stratum level present in the data, rather than
erroring – a log-rank test needs at least 2 groups to compare. Other
builders (e.g. er_style_tte_summary_n()) work regardless of
stratification.
The input object, with the summary layer added.
The following pre-defined styles are available for this layer. Please see the documentation for the corresponding builder function to see what customisation options are available:
| Label | Builder | Description |
"logrank" | er_style_tte_summary_logrank() | Log-rank test p-value comparing survival across stratify_by's levels (the default). |
"n" | er_style_tte_summary_n() | Subject/event counts; model- and stratification-agnostic. |
"coefficients" | er_style_tte_summary_coefficients() | One line per model parameter, from model's er_summary() coefficients table. |
"gof" | er_style_tte_summary_gof() | A goodness-of-fit annotation from model's er_summary() glance table. |
See er_style_tte() for details on how style builder functions are
defined for the TTE mini-grammar, should a custom style be required.
er_tte(), er_style_tte_summary_logrank()
library(survival)
lung |>
transform(sex = factor(sex, labels = c("Male", "Female"))) |>
er_tte(time, status == 2, stratify_by = sex) |>
er_tte_add_curve() |>
er_tte_add_summary() |>
plot()
# a purely descriptive annotation, with no model or log-rank test at all
lung |>
er_tte(time, status == 2) |>
er_tte_add_curve() |>
er_tte_add_summary(style = er_style_tte_summary_n) |>
plot()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.