Declares a glue action to concatenate a value — from a data column or a
literal string — to the display text of specified cells in rows matching
the parent compute_cols() condition.
Arguments
- cols
Tidyselect expression for the target columns (e.g.,
col1,c(col1, col2),starts_with("x")). Must resolve to visible (non-hidden) report columns only.- position
Character. Concatenation side:
"before"prepends the glue value to the existing cell text;"after"appends it.- glue_col
Optional. Unquoted column name whose formatted value is concatenated onto the target cells. The column may be hidden (not in the visible column list). Mutually exclusive with
text.- text
Optional. A single literal character string to concatenate onto the target cells. Mutually exclusive with
glue_col.- separator
Character string inserted between the existing cell text and the glued value when both sides are non-empty. Defaults to
""(direct concatenation). When either side is empty, no separator is inserted.
Value
Quosure-style marker (internal use within compute_cols())
Details
Must be called inside compute_cols().
Constraints:
Exactly one of
glue_colortextmust be provided.colsresolves only visible report columns via tidyselect.glue_colcan reference any data column, including hidden ones.glue_colmust not overlap withcols.
Behavior:
When the glue value (from
glue_colortext) is empty orNA, the action is silently skipped for that row/cell.When a target cell was suppressed by deduplication (
dedupe = TRUEon that column), the glue is silently skipped to preserve the visual suppression of repeated values.When a target cell is suppressed by a concurrent
c_merge()action (i.e., it is a non-leader merged cell), the glue is silently skipped.The merge leader cell is glued normally when
c_glue()targets a column involved inc_merge()as the first column.Multiple
c_glue()calls on the same column accumulate in call order.
Interaction with other actions:
c_style(): Fully compatible — styling and text modification are independent.c_merge(): Compatible. Glue is processed after merge in the renderer. Non-leader (suppressed) merge cells are skipped; the merge-leader cell is glued normally.c_addrow(): Stackable — when used together in the samecompute_cols(),c_addrow()sees glued values. This allows building compound cell values (e.g., "PARAM: VISIT") before using them in inserted rows.c_pageBreak(): Fully compatible.
Stackable Actions:
Actions within a single compute_cols() call execute sequentially in the order
specified. This means c_glue() modifications are visible to subsequent c_addrow()
actions in the same call, enabling complex multi-step transformations.
Examples
if (FALSE) { # \dontrun{
# Append a unit from a hidden column (e.g. unit_col is not in spec cols)
spec <- compute_cols(spec, !is.na(value),
c_glue(value, "after", glue_col = unit, separator = " "))
# Prepend a literal marker to a label column
spec <- compute_cols(spec, is_total,
c_glue(label, "before", text = ">> "))
# Combine with c_style() — independent operations
spec <- compute_cols(spec, firstOf(group),
c_glue(label, "before", text = "> "),
c_style(label, styleRef = "bold"))
# Stackable with c_addrow() — addrow sees glued values
spec <- compute_cols(spec, PARAM == "ALT",
c_glue(PARAM, "after", glue_col = VISIT, separator = ": "),
c_addrow("above", value_from = PARAM) # Uses "ALT: Week 2"
)
} # }