The cell_fill()
function
Use exibble
to create a gt table. Add styles with tab_style()
and the cell_fill()
helper function.
exibble |>
dplyr::select(num, currency) |>
gt() |>
fmt_number(
columns = c(num, currency),
decimals = 1
) |>
tab_style(
style = cell_fill(color = "lightblue"),
locations = cells_body(
columns = num,
rows = num >= 5000
)
) |>
tab_style(
style = cell_fill(color = "gray85"),
locations = cells_body(
columns = currency,
rows = currency < 100
)
)
num |
currency |
0.1 |
50.0 |
2.2 |
17.9 |
33.3 |
1.4 |
444.4 |
65,100.0 |
5,550.0 |
1,325.8 |
NA |
13.3 |
777,000.0 |
NA |
8,880,000.0 |
0.4 |