| as_json | R Documentation |
The whole result as JSON, under a documented and versioned schema, for software that consumes changepoint results rather than a person reading them.
as_json(x, ...)
## S3 method for class 'ggcpt'
as_json(x, pretty = TRUE, data = TRUE, assumptions = TRUE, digits = NA, ...)
## Default S3 method:
as_json(x, ...)
x |
A |
... |
Ignored. |
pretty |
Indent the output? Defaults to |
data |
Include the series itself ( |
assumptions |
Include |
digits |
Significant digits for numbers. Defaults to |
A single string of class "json".
One object with these fields. Every field is always present; one that
does not apply is null, so a reader never has to test for a key.
schema, schema_version"ggchangepoint.ggcpt"
and the version, "1.0.0".
method, engine, engine_version,
ggchangepoint_version, r_version, createdwhat produced the result, and when (ISO 8601).
change_in, familywhat was detected, and the distribution family if one was asked for.
penalty{"type", "value"}.
cp_convention"left": a changepoint is the last
observation of its segment.
nthe series length.
index{"class", "label", "tz"} of the time
index, or null. Dates are written as ISO 8601 strings and
timestamps with their offset; tz is a timestamp index's time
zone (null otherwise).
changepointsan array of objects, one per changepoint:
cp (position) and cp_value, with cp_index when
there is an index, and every engine-specific column
(ci_lower, ci_upper, posterior_prob, ...).
segmentsseg_id, start, end,
n, param_estimate.
regions, coefficients, constraintsthe
optional slots, as arrays of objects (or an object), or null.
diagnosticsresidual_dependence (Ljung-Box
p_value, lag, acf1), na_omitted and
expected_false_positives where recorded.
assumptionsthe cpt_assumptions() rows, or
null.
callthe call that made the result, as text.
data{"index", "value", "fitted",
"coordinates"} arrays, or null. coordinates is an
object with one array per coordinate of a multivariate result
(null for a single series), whose first is value.
cpt_export() to write a file,
cpt_import() to read one back,
cpt_report(format = "json").
Other result class:
annotate_segments(),
as_cpt_series(),
as_ggcpt(),
cpt_annotations(),
cpt_export(),
cpt_verify(),
ggchangepoint-conditions,
is_ggcpt(),
new_ggcpt(),
print.ggcpt()
set.seed(1)
fit <- cpt_detect(c(rnorm(50), rnorm(50, 3)), method = "pelt")
cat(as_json(fit, data = FALSE))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.