util_formattable: Plots simple HTML tables with background color scale

View source: R/util_formattable.R

util_formattableR Documentation

Plots simple HTML tables with background color scale

Description

Plots simple HTML tables with background color scale

Usage

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")
)

Arguments

tb

data.frame the table as data.frame with mostly numbers

min_val

numeric minimum value for the numbers in tb

max_val

numeric maximum value for the numbers in tb

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.

Value

htmltools compatible object

See Also

util_html_table()

Examples

## 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)


dataquieR documentation built on May 29, 2024, 7:18 a.m.