gt_color_box {gtExtras} | R Documentation |
Add a small color box relative to the cell value.
Description
Create PFF
-style colorboxes in a gt
table.
Note that rather than using gt::fmt_
functions on this column, you can send
numeric formatting arguments via ...
. All arguments should be named
and are passed to scales::label_number()
.
Usage
gt_color_box(
gt_object,
columns,
palette = NULL,
...,
domain = NULL,
width = 70,
font_weight = "bold"
)
Arguments
gt_object |
An existing gt table object of class |
columns |
The columns wherein changes to cell data colors should occur. |
palette |
The colours or colour function that values will be mapped to. Can be a character vector (eg |
... |
Additional arguments passed to |
domain |
The possible values that can be mapped. This should be a simple numeric range (e.g. |
width |
The width of the entire coloring area in pixels. |
font_weight |
A string indicating the font weight, defaults to |
Value
An object of class gt_tbl
.
Examples
library(gt) test_data <- dplyr::tibble(x = letters[1:10], y = seq(100, 10, by = -10), z = seq(10, 100, by = 10)) color_box_tab <- test_data %>% gt() %>% gt_color_box(columns = y, domain = 0:100, palette = "ggsci::blue_material") %>% gt_color_box(columns = z, domain = 0:100, palette = c("purple", "lightgrey", "green"))
Figures
Function ID
4-3
See Also
Other Colors:
gt_color_rows()
,
gt_hulk_col_numeric()