View source: R/util_formattable.R
util_formattable | R Documentation |
Plots simple HTML tables with background color scale
util_formattable(
tb,
min_val = min(tb, na.rm = TRUE),
max_val = max(tb, na.rm = TRUE),
min_color = c(0, 0, 255),
max_color = c(255, 0, 0),
soften = function(x) stats::plogis(x, location = 0.5, scale = 0.1),
style_header = "font-weight: bold;",
text_color_mode = c("bw", "gs")
)
tb |
data.frame the table as data.frame with mostly numbers |
min_val |
numeric minimum value for the numbers in |
max_val |
numeric maximum value for the numbers in |
min_color |
numeric vector with the RGB color values for the minimum color, values between 0 and 255 |
max_color |
numeric vector with the RGB color values for the maximum color, values between 0 and 255 |
soften |
function to be applied to the relative values between 0 and 1 before mapping them to a color |
style_header |
character to be applied to style the HTML header of the table |
text_color_mode |
enum bw | gs. Should the text be displayed in black and white or using a grey scale? In both cases, the color will be adapted to the background. |
htmltools
compatible object
util_html_table()
## Not run:
tb <- as.data.frame(matrix(ncol = 5, nrow = 5))
tb[] <- sample(1:100, prod(dim(tb)), replace = TRUE)
tb[, 1] <- paste("case", 1:nrow(tb))
htmltools::browsable(util_formattable(tb))
htmltools::browsable(util_formattable(tb[, -1]))
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.