huxtable (version 1.2.0)

background_color: 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 vector or matrix of R colors. 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

Run this code
# NOT RUN {
ht <- huxtable(a = 1:3, b = 1:3)
background_color(ht) <-  grey(.95)
background_color(ht)


ht <- huxtable(a = 1:3, b = 3:1)
ht2 <- set_background_color(ht, grey(.95))
background_color(ht2)
ht3 <- set_background_color(ht, 1:2, 1, grey(.95))
background_color(ht3)
ht4 <- set_background_color(ht, 1:2, 1:2, c(grey(.95), 'yellow'), byrow = TRUE)
background_color(ht4)
ht5 <- set_background_color(ht, where(ht == 1), grey(.95))
background_color(ht5)
# }

Run the code above in your browser using DataCamp Workspace