Skip to contents

plot_corpairs() is a small ggplot2 consumer for tables returned by corpairs(). It does not compute correlation pairs, fit intervals, or choose a correlation layer. Build the table first with corpairs(), then pass that table to this helper.

Usage

plot_corpairs(
  data,
  colour = "level",
  facet = NULL,
  label = NULL,
  interval = TRUE,
  ...
)

Arguments

data

A data frame returned by corpairs(), or a compatible table with columns level, class, parameter, estimate, and modelled. conf.status and interval_source are optional for point-only tables, but finite intervals are drawn only when those columns mark a supported interval.

colour

Optional character scalar naming a column to map to colour. Use NULL to suppress colour mapping.

facet

Optional character scalar naming a column to facet by. Use NULL to suppress faceting.

label

Optional character scalar naming a column to use for y-axis row labels. Use this for publication figures where the full level | class | parameter label is too long. If NULL, labels are built from level, class, and parameter.

interval

Logical; draw finite conf.low/conf.high intervals when those columns are present.

...

Reserved for future options.

Value

A ggplot object.

Details

The helper draws one point per correlation row. If the table contains finite conf.low and conf.high bounds plus interval provenance columns that describe a real interval, it draws interval segments for those rows only. Rows without supported bounds remain visible as point estimates and keep their display interval status attached to the plotted data.

Examples

pairs <- data.frame(
  level = c("residual", "group"),
  class = c("residual", "mean-slope"),
  parameter = c("rho12", "cor((Intercept),x | p | id)"),
  estimate = c(0.25, 0.45),
  modelled = c(FALSE, FALSE),
  conf.low = c(NA, 0.10),
  conf.high = c(NA, 0.72),
  conf.status = c("not_requested", "profile"),
  interval_source = c("not_available", "profile")
)
if (requireNamespace("ggplot2", quietly = TRUE)) {
  plot_corpairs(pairs)
  plot_corpairs(pairs, facet = "level")
}