Bolds the body cells of chosen rows, with an option to recolor their text and fill their background. Rows are chosen by index or by a filter expression; with neither, every row is bolded.
Arguments
- gt_object
A
gttable object to modify.- rows
The rows to bold. Either an expression evaluated against the table's data, such as
wins > 10, or a numeric vector of row indices. IfNULL, every row is bolded. Defaults toNULL.- text_color
Character. The text color for the bolded rows. Defaults to
"black".- highlight_color
Character. The background fill for the bolded rows. Set to
NULLfor no fill. Defaults toNULL.
Details
rows is evaluated against the table's underlying data, so rows = wins > 10
bolds the rows where that is TRUE; a numeric vector picks rows by index. The
styling is applied with a single
gt::tab_style() over gt::cells_body(), so it covers every column of the
chosen rows.
Examples
library(gt)
nfc_west <- subset(
sdv_example_standings, division == "NFC West",
c(team_name, wins:points_against)
)
# bold every row
gt(nfc_west) |> gt_bold_rows()
team_name
wins
losses
ties
win_pct
points_for
points_against
# bold and fill the teams with a winning record
gt(nfc_west) |>
gt_bold_rows(rows = win_pct > 0.5, highlight_color = "#FFF3B0")
team_name
wins
losses
ties
win_pct
points_for
points_against
