R: Background color

background_color {huxtable} | R Documentation

## Background color

### Description

Functions to get or set the background color property of huxtable table cells.

### Usage

    background_color(ht)
    background_color(ht) <- value
    set_background_color(ht, row, col, value, byrow = FALSE)

### Arguments

`ht` | A huxtable.
`value` | A character vector or matrix of valid R color names. Set to `NA` to reset to the default.
`row` | A row specifier. See `rowspecs` for details.
`col` | An optional column specifier.
`byrow` | If `TRUE`, fill in values by row rather than by column.

### Value

For `background_color`, the `background_color` attribute. For `set_background_color`, the `ht` object.

### See Also

Other formatting functions: `bold`, `font_size`, `font`, `na_string`, `number_format`, `text_color`

### Examples

    ht <- huxtable(a = 1:3, b = 1:3)
    background_color(ht) <-  grey(.95)
    background_color(ht)

    ht <- huxtable(a = 1:3, b = 3:1)
    set_background_color(ht, grey(.95))
    set_background_color(ht, 1:2, 1, grey(.95))
    set_background_color(ht, 1:2, 1:2, c(grey(.95), 'yellow'), byrow = TRUE)
    set_background_color(ht, where(ht == 1), grey(.95))

[Package huxtable version 3.0.0 Index]