This function applies background colors to rows based on tier levels and bolds
the tier column in a gt
table. It iterates over the specified levels and
applies the corresponding colors to the rows that match each tier. The text color
for the tier
column is determined using gt:::ideal_fgnd_color
for better contrast.
Usage
gt_tiers(gt_object, levels, colors, style = "dark", img_height = "55px")
Arguments
- gt_object
A gt
table object to modify.
- levels
A character vector specifying the tier levels. These should match
the factor levels in the tier
column of the table.
- colors
A character vector of hex color codes corresponding to the tier levels.
The length of colors
must match the length of levels
.
Value
Returns a modified gt
table with tier-based background colors and bold text applied.
Details
The function applies background colors based on the levels
vector to the rows where
the tier
column matches the level. It also bolds the text in the tier
column for
clearer differentiation and uses gt:::ideal_fgnd_color
to determine the appropriate
text color for the background.