Several rows in one cell recipe, each with its own fallback chain
Source:R/ard_tables.R
cell_rows.Rdcells already reads three containers: one template is one row, a named
character vector is one row per element, and a list() is a map looked up
by analysis variable. The one shape those cannot spell is a named row
whose value is itself a chain – c("1" = c(a, b)) is flattened by c()
before widen_ard() ever sees it. cell_rows() is that shape, and only
that shape.
Value
An object of class cell_rows, for cells in widen_ard().
Details
Each argument is one output row: its name is the row label, its value is a
template, a chain of templates, or a chain with guards. Reading a recipe
then goes list() for which variable, cell_rows() for which row,
c() for which template to try first.
Examples
# an estimate line and a confidence-interval line, the first guarded so a
# count of zero prints as "0" rather than "0 (0.0)"
cell_rows(
"1" = c(n == 0 ~ "0", "{n:.0f} ({estimate:.1f%})"),
"2" = "{conf.low:.1f%}, {conf.high:.1f%}")
#> <cell_rows> 2 row(s)
#> 1 n == 0 ~ "0" | {n:.0f} ({estimate:.1f%})
#> 2 {conf.low:.1f%}, {conf.high:.1f%}