Skip to contents

Builds a complete statistical-output document from the result tables of ONE .jasp/.omv file or executed R script: one document per source file, with an analyses array (one element per analysis heading/table) each carrying a results array (one element per result row) of STATO-typed statistic values (via stato_type_column()). This is a metacheck-native schema — a flat, self-describing document in the character of OSD/DDI-Lifecycle/Psych-DS — not a repurposing of an unrelated external standard's vocabulary; there is no external schema this validates against.

Usage

stat_output_json(tables, paper_id = "metacheck", source_file = NA_character_)

Arguments

tables

the list returned by read_stat_tables() or read_r_output()

paper_id

paper id / DOI, recorded on the document

source_file

basename of the originating .jasp/.omv, or the R script name for run-R output, recorded as source_file and used to derive source_format and the result_id prefix (see below)

Value

a list ready to serialise with jsonlite::toJSON(auto_unbox = TRUE), with elements schema, schema_version, paper_id, source_file, source_format, and analyses (a list of list(analysis, results), where each result is list(result_id, row_label, values) and values is a named list keyed by the statistic's own short name, e.g. t/df/p/d, each a list(value, stato_label, stato_iri) — stato_label/stato_iri omitted when stato_type_column() found no class for that statistic). NULL when there are no tables or no table yields any typed value. result_id identifies the CODE ROW that produced it — see stat_results_long() for the id format (shared between both serialisations of one extraction).

Examples

out <- utils::capture.output(t.test(extra ~ group, data = sleep))
doc <- stat_output_json(read_r_output(out), paper_id = "demo")
names(doc)
#> [1] "schema"         "schema_version" "paper_id"       "source_file"   
#> [5] "source_format"  "analyses"