
Write extracted statistical output to a dedicated folder
Source:R/stat-output.R
stat_output_write.RdWrites reproducibility_check's accumulated stat_output (one element per
source file: JASP/jamovi files via read_stat_tables(), executed R scripts
via read_r_output()) to <root>/statistical_output/, a folder sibling to
the materialised data/ — so the extracted statistics sit alongside the data
and code that produced them. Two views are written from the SAME extraction:
one combined results_long.csv (every source file's stat_results_long()
rows stacked, one row per extracted statistic, easiest to load and filter),
and one <codename>.statistical_output.json per source file (its
stat_output_json() document). Called from inside reproducibility_check
itself (not from the later psychds/scienceverse conversion step), so the
folder exists at the same point in the pipeline the data/code files do.
Arguments
- stat_output
a list as accumulated by
reproducibility_check— each element a list withfile(source file name),json(stat_output_json()'s document), andlong(stat_results_long()'s table)- root
the materialised layout root (the same directory
data/is copied into);statistical_output/is created under it
Value
the path to statistical_output/, invisibly, or NULL (nothing
written) when stat_output is empty or carries no rows/documents.
Examples
out <- utils::capture.output(t.test(extra ~ group, data = sleep))
tables <- read_r_output(out, source_label = "analysis.R")
so <- list(list(file = "analysis.R",
json = stat_output_json(tables, source_file = "analysis.R"),
long = stat_results_long(tables, source_file = "analysis.R")))
dir <- stat_output_write(so, file.path(tempdir(), "stat_demo"))
list.files(dir)
#> [1] "analysis.statistical_output.json" "results_long.csv"