Skip to contents

Declares an additional row to be inserted above or below rows matching the parent compute_cols() condition. Content can optionally be copied from a specified column; if omitted, creates an empty separator row.

Usage

c_addrow(pos, value_from = NULL, styleRef = NULL)

Arguments

pos

Character. Position for insertion: "above" or "below".

value_from

Character or unquoted column name. Optional source column for the inserted row's content. If NULL or missing, creates an empty separator row.

styleRef

Character vector or result of f_combine(). Optional style to apply to the inserted row. If NULL, no special styling.

Value

Quosure structure (internal use within compute_cols())

Details

Must be called inside compute_cols().

Behavior:

  • Multiple c_addrow() calls in one compute_cols() accumulate

  • Order of appearance is preserved

  • Coexists with other actions on same row

  • If value_from is provided, must exist in spec columns (data_env reference)

  • If value_from is NULL or missing, creates an empty separator row

Stackable Actions: Actions within a single compute_cols() call execute sequentially in the order specified. This means c_addrow() can see values modified by earlier c_glue() actions, allowing you to build compound cell values (e.g., "PARAM: VISIT") before using them in inserted rows. Multiple c_glue() and c_addrow() calls can be interleaved as needed.

See also

compute_cols() for conditional row actions, c_style(), c_merge() for other action types

Examples

if (FALSE) { # \dontrun{
  compute_cols(spec, lastOf(treatment), c_addrow(pos = "below", value_from = "treatment"))
  compute_cols(spec, firstOf(visit), c_addrow(pos = "above"))
  
  # Stackable: addrow sees glued value
  compute_cols(spec, PARAM == "ALT",
    c_glue(PARAM, "after", glue_col = VISIT, separator = ": "),
    c_addrow("above", value_from = PARAM)  # Uses "ALT: Week 2"
  )
} # }