R: Border styles

left_border_style {huxtable} | R Documentation

## Border styles

### Description

Functions to get or set the border styles property of huxtable cells.

### Usage

    left_border_style(ht)
    left_border_style(ht) <- value
    set_left_border_style(ht, row, col, value, byrow = FALSE)

    right_border_style(ht)
    right_border_style(ht) <- value
    set_right_border_style(ht, row, col, value, byrow = FALSE)

    top_border_style(ht)
    top_border_style(ht) <- value
    set_top_border_style(ht, row, col, value, byrow = FALSE)

    bottom_border_style(ht)
    bottom_border_style(ht) <- value
    set_bottom_border_style(ht, row, col, value, byrow = FALSE)

### Arguments

`ht` | A huxtable.
`value` | A character vector or matrix of styles, which may be "solid", "double", "dashed" or "dotted". Set to `NA` to reset to the default, which is `"solid"`.
`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.

### Details

Huxtable collapses borders and border colors. Right borders take priority over left borders, and top borders take priority over bottom borders.

Border styles only apply if the border width is greater than 0.

### Value

For `left_border_style`, the `left_border_style` property. For `set_left_border_style`, the `ht` object.

Similarly for the other functions.

### Quirks

- In HTML, you will need to set a width of at least 3 to get a double border.

- Only "solid" and "double" styles are currently implemented in LaTeX.

### Note

huxtable currently sets borders on specific cells. This can lead to surprising behaviour when cells span multiple rows or columns: see the example. This behaviour may be improved in a future release.

### Examples

    ht <- huxtable(a = 1:3, b = 3:1)
    ht <- set_all_borders(ht, 1)
    set_left_border_style(ht, 'double')
    set_left_border_style(ht, 1:2, 1, 'double')
    set_left_border_style(ht, 1:2, 1:2, c('solid', 'double'), byrow = TRUE)
    set_left_border_style(ht, where(ht == 1), 'double')
    # When cells span multiple rows:
    ht <- tribble_hux(
      ~Col1,                   ~Col2,
      "Cell 1,1 spans 2 rows", "Cell 1,2",
      "Cell 2,1 is invisible", "Cell 2,2"
    )
    rowspan(ht)[1, 1] <- 2
    ht
    bottom_border(ht)[2, ] <- 1
    bottom_border_color(ht)[2, ] <- 'red'
    # Cell 1, 1 does not have a border set:
    ht
    # Fixed:
    bottom_border(ht)[1, 1] <- 1
    bottom_border_color(ht)[1, 1] <- 'red'
    ht

[Package huxtable version 4.2.0 Index]