| pa_plot_summary | R Documentation |
Builds one panel per data frame using plot_fun (default: pa_plot_pred)
and arranges them with letter tags. The function collects a single shared legend
and applies global styling (titles, axis labels, legend options) across panels.
pa_plot_summary(
data_list,
titles = NULL,
plot_fun = pa_plot_pred,
ncol = 2,
tag_levels = "a",
invert_linear = TRUE,
xlab = "Risk Score",
ylab = "Days",
label_name = c("Censored", "Event"),
levels = NULL,
shape_style = NULL,
sample_size = NULL,
restrict_time = NULL,
legend_name = "Status",
seed = NULL
)
data_list |
List of data frames, each containing columns:
|
titles |
Optional character vector, same length as |
plot_fun |
Function that creates a single panel (default = |
ncol |
Number of columns in the panel layout (default = 2). |
tag_levels |
Letter style for tags: |
invert_linear |
Logical or logical vector; if length 1, recycled to all panels. |
xlab, ylab |
Axis labels applied to all panels (defaults are "Risk Score" and "Days"). |
label_name |
Character vector of labels for status legend (e.g., |
levels |
Numeric vector for |
shape_style |
Numeric vector of plotting symbols for censoring/event status. |
sample_size |
Optional integer. If supplied, that many subjects are
sampled at random for each panel using |
restrict_time |
Optional numeric. If supplied, observed times above this value are capped at it and a dashed horizontal reference line is drawn, which keeps a few long follow-up times from compressing the plot. |
legend_name |
Character string for the legend title (default = "status"). |
seed |
Optional integer. If supplied, the random number generator is
seeded with it before |
A patchwork ggplot object combining all panels.
# One panel per model. The previous example referenced undefined objects and
# so could not be executed; this one runs.
d <- pa_sim_cox_weibull(n = 150, pi_c = 0.3, v = 2,
beta = c(0.5, -0.5), seed = 2025)
d <- d[, c("time", "status", "x1", "x2")]
cox <- survival::coxph(survival::Surv(time, status) ~ x1 + x2,
data = d, x = TRUE, y = TRUE)
wei <- survival::survreg(survival::Surv(time, status) ~ x1 + x2,
data = d, dist = "weibull", x = TRUE, y = TRUE)
p_cox <- pa_predict_coxph(model = cox, covs = c("x1", "x2"), new_data = d)
p_wei <- pa_predict_survreg(model = wei, covs = c("x1", "x2"), new_data = d)
pa_plot_summary(
list(p_cox, p_wei),
titles = c("Cox PH", "Weibull AFT"),
ncol = 2,
legend_name = "Status"
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.