cpt_report: A reproducible report of a changepoint analysis

View source: R/communicate.R

cpt_reportR Documentation

A reproducible report of a changepoint analysis

Description

Assembles everything a reader needs to judge a changepoint result into one artifact: the method and its citation, the penalty, the number and locations of the changepoints with intervals where available, the segment table, stability and diagnostics if they were computed, and the session information. Reproducibility and correct attribution in one call.

Usage

cpt_report(
  object,
  format = c("md", "text", "gt", "json"),
  file = NULL,
  stability = NULL,
  events = NULL,
  confint = TRUE,
  session = TRUE
)

Arguments

object

A ggcpt object.

format

"md" (default, GitHub-flavoured markdown as a character vector), "text" (plain text), "gt" (a gt table of the changepoints, for a publication) or "json" (the whole result under as_json()'s versioned schema, for a pipeline rather than a reader).

file

Optional path to write to. The report is returned invisibly when a file is written. Ignored for format = "gt", which returns a table object rather than lines of text.

stability

Optional cpt_stability() result to include.

events

Optional cpt_annotate_events() result to include.

confint

Include a cpt_confint() table? Defaults to TRUE, which uses the engine's own intervals when it has them and skips the section otherwise (rather than silently bootstrapping, which would be slow and unexpected inside a report).

session

Include sessionInfo()? Defaults to TRUE.

Value

A character vector of report lines (or a gt table when format = "gt").

See Also

cpt_gt(), cpt_cite().

Examples

set.seed(2026)
fit <- cpt_detect(c(rnorm(60), rnorm(60, 4)), method = "pelt")
cat(cpt_report(fit, session = FALSE), sep = "\n")

ggchangepoint documentation built on Nov. 5, 2026, 9:06 a.m.