Skip to contents

Walks an assembled report (or any table of contrasts) and turns it into the named values cr_macros() emits: the disposition counts, one entry per contrast and numeric column, and the enumerations that a sentence would otherwise state by hand — which intervals exclude the null, and how many. Enumerations are the entries most worth generating, because a hand-typed list is wrong as soon as one row of the analysis changes.

Usage

cr_macros_from(x, file, label_cols = NULL, ci = c("ci_low", "ci_high"), ...)

Arguments

x

A cr_report, or a data frame with one row per contrast.

file

Output path, or NULL to return the lines.

label_cols

Character vector naming the columns that identify a row. NULL (default) picks the first available of group, compound, treatment, term, name, together with contrast or comparison when present.

ci

Names of the lower and upper confidence-bound columns, used for the "excludes zero" enumerations. NULL disables them.

...

Passed to cr_macros() (format, prefix, digits, ...).

Value

The output path (invisibly), or a character vector of lines when file is NULL.

Examples

eff <- data.frame(
  group = c("CompoundA", "CompoundB", "CompoundC"),
  estimate = c(1.42, 0.31, -0.88),
  ci_low = c(0.55, -0.10, -1.60),
  ci_high = c(2.29, 0.72, -0.16)
)
cat(cr_macros_from(eff, file = NULL), sep = "\n")
#> % Generated by cellreportR -- do not edit by hand.
#> % Every value is derived from the analysis object. If one looks
#> % wrong, fix the analysis and emit this file again.
#> 
#> \newcommand{\CompoundAestimate}{1.420}
#> \newcommand{\CompoundBestimate}{0.310}
#> \newcommand{\CompoundCestimate}{-0.880}
#> \newcommand{\CompoundAcilow}{0.550}
#> \newcommand{\CompoundBcilow}{-0.100}
#> \newcommand{\CompoundCcilow}{-1.600}
#> \newcommand{\CompoundAcihigh}{2.290}
#> \newcommand{\CompoundBcihigh}{0.720}
#> \newcommand{\CompoundCcihigh}{-0.160}
#> \newcommand{\excludeszero}{CompoundA and CompoundC}
#> \newcommand{\nexcludeszero}{2}
#> \newcommand{\ncontrasts}{3}