highlight_max: Highlights the maximum value in a column

View source: R/highlight_max.R

highlight_maxR Documentation

Highlights the maximum value in a column

Description

The 'highlight_max()' function assigns a font color and/or background color to the maximum value in a column. It should be placed within the style argument in reactable::colDef.

Usage

highlight_max(data, font_color = "green", highlighter = NULL)

Arguments

data

Dataset containing at least one numeric column.

font_color

color to assign to maximum value in a column. Default color is green.

highlighter

color to assign the background of a cell containing maximum value in a column.

Value

a function that applies a color to the maximum value in a column of numeric values.

Examples

data <- MASS::road[11:17, ]

## By default, the maximum value is bold with a green font color
reactable(data,
defaultColDef = colDef(
    style = highlight_max(data)))

## Assign a different font color
reactable(data,
defaultColDef = colDef(
    style = highlight_max(data,
    font_color = "red")))

## Highlight the background of the cell for the maximum value in each column
reactable(data,
defaultColDef = colDef(
    style = highlight_max(data,
    highlighter = "yellow")))


reactablefmtr documentation built on March 18, 2022, 5:08 p.m.