The `pos_neg_colors()` function assigns a color to all negative values and a color to all positive values. It should be placed within the style argument in reactable::colDef.
Arguments
- neg_col
color to assign to negative values.
- pos_col
color to assign to positive values.
- bold
optional argument to bold values. Default is set to NULL or not bold.
Examples
data <- data.frame(
Symbol = c("GOOG", "FB", "AMZN", "NFLX", "TSLA"),
Price = c(1265.13, 187.89, 1761.33, 276.82, 328.13),
Change = c(4.14, 1.51, -19.45, 5.32, -12.45))
## Assign the color red to negative values and green to positive values
reactable(data,
columns = list(
Change = colDef(
style = pos_neg_colors("red", "green"))))
#> Error in x$width %||% settings$fig.width * settings$dpi: non-numeric argument to binary operator
## Bold values
reactable(data,
columns = list(
Change = colDef(
style = pos_neg_colors("red", "green", bold = TRUE))))
#> Error in x$width %||% settings$fig.width * settings$dpi: non-numeric argument to binary operator