Declares a style or combination of styles to be applied to specified columns
in rows matching the parent compute_cols() condition.
Arguments
- cols
Tidyselect expression for column selection (e.g.,
c(col1, col2),everything(),starts_with("x"))- styleRef
Character. Name of the style to apply (defined via
add_style()). Can be a single style name (e.g.,"bold") or result off_combine()for combining multiple styles (e.g.,f_combine("bold", "red")). When multiple styles are provided viaf_combine(), they are merged in the order listed (last wins for conflicting properties).
Value
Quosure structure (internal use within compute_cols())
Details
Must be called inside compute_cols(). Columns are resolved using
tidyselect syntax against the table data.
Behavior:
Same column styled multiple times in one row: last style wins, warning issued
Same column styled from different
compute_cols()calls on same row: non-conflicting properties COMBINE (e.g. bold then italic yields bold-italic); on a conflicting property the later block wins (automatic style combination consolidated viacreate_report()).Multiple columns in one call: all receive the same style(s)
Style Combination:
Use
f_combine("style1", "style2")to apply multiple styles togetherDuring
create_report(), combined styles are consolidated into a single hashConsolidation only happens for new specs (not pre-processed reports)
See also
compute_cols() for conditional row actions, c_merge(), c_addrow() for other action types
Examples
spec <- create_table(mtcars) |>
add_style("bold", s_font(bold = TRUE)) |>
add_style("red", s_font(color = "red"))
# Single style on one column
spec <- compute_cols(spec, cyl == 6, c_style(mpg, styleRef = "bold"))
# Single style on multiple columns
spec <- compute_cols(spec, hp > 100, c_style(c(mpg, wt), styleRef = "red"))
# Combined styles on columns (last argument wins per property)
spec <- compute_cols(spec, cyl == 8, c_style(mpg, styleRef = f_combine("bold", "red")))