Skip to contents

cells 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.

Usage

cell_rows(...)

Arguments

...

One argument per output row. Names become row labels; an unnamed argument takes its label from label, as a bare template does.

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%}