| gt_color_box | R Documentation |
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().
gt_color_box(
gt_object,
columns,
palette = NULL,
...,
domain = NULL,
width = 70,
font_weight = "bold"
)
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 |
An object of class gt_tbl.
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"))
4-3
Other Colors:
gt_color_rows(),
gt_hulk_col_numeric()
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.