Skip to contents

Checks that a stat_output_json() document has the required top-level fields, that analyses is a list of list(analysis, results), and that every result carries a result_id and a non-empty values object whose entries each have a value. This is a native structural check, not an executed external JSON Schema — there is no external standard this document conforms to, by design (see the file header comment). Mirrors behaverse_validate()'s and psychds-validate.R's hand-rolled approach.

Usage

stat_output_validate(doc)

Arguments

doc

a statistical-output document as an R list (as from stat_output_json()), or a length-1 character path / JSON string to parse first.

Value

a list with valid (TRUE when no issues), issues (a character vector of problem descriptions), and summary (n_errors, n_analyses, n_results).

Examples

out <- utils::capture.output(t.test(extra ~ group, data = sleep))
doc <- stat_output_json(read_r_output(out), paper_id = "demo")
stat_output_validate(doc)$valid
#> [1] TRUE