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.
See also
compute_cols() for conditional row actions, c_merge(), c_addrow() for other action types
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: automatic style combination (merged 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)
Examples
if (FALSE) { # \dontrun{
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
spec <- compute_cols(spec, cyl == 8, c_style(mpg, styleRef = f_combine("bold", "red")))
} # }