Skip to contents

Declares a clear action that blanks the display text of specified cells in rows matching the parent compute_cols() condition. The cells are rendered empty without affecting their column structure, width, or styling.

Usage

c_clear(cols)

Arguments

cols

Tidyselect expression for the target columns to blank (e.g., col1, c(col1, col2), starts_with("x")). Must resolve to visible (non-hidden) report columns only.

Value

Quosure-style marker (internal use within compute_cols())

Details

Must be called inside compute_cols().

Behavior:

  • Sets the RENDERED cell text to "" for matching rows. The clear is display-only: conditions in compute_cols() keep seeing the RAW data values, and the column still participates in width/format resolution.

  • Actions execute in ARRIVAL order (argument order within the call, then pipe order across calls) — clear is not automatically "first". Placing c_clear() before c_glue() on the same column turns the pair into a full REPLACEMENT (glue lands on the emptied cell); placing c_glue() before c_clear() wipes the cell afterwards.

  • Compatible with c_style(): styling is independent of text content.

  • When c_merge() spans a cleared leader cell, the merged span renders as a blank merged cell.

Examples

  spec <- create_table(mtcars)

  # Blank the disp column for four-cylinder rows
  spec <- compute_cols(spec, cyl == 4, c_clear(disp))

  # Clear then re-fill from another column (full replacement:
  # canonical merge -> clear -> glue ordering inside ONE call)
  spec2 <- create_table(mtcars) |>
    compute_cols(hp == 62,
      c_clear(carb),
      c_glue(carb, "after", text = "-"))