| pad_decimal {huxtable} | R Documentation |
Functions to get or set the decimal padding property of huxtable table cells.
pad_decimal(ht) pad_decimal(ht) <- value set_pad_decimal(ht, row, col, value, byrow = FALSE)
ht |
A huxtable. |
value |
A vector of single characters. |
row |
A row specifier. See |
col |
An optional column specifier. |
byrow |
If |
LaTeX and HTML both have no simple way to align columns on decimal points, especially when cells
may contain non-mathematical content like significance stars. To right-pad cells
in a column to align on the rightmost decimal point, set pad_decimal to '.' or whatever decimal
you prefer to use. Note that this will only work for cells with align set to 'right'.
For pad_decimal, the pad_decimal attribute.
For set_pad_decimal, the ht object.
vals <- c(1.00035, 22, "2.34 *", "(11.5 - 22.3)", "Do not pad this row.")
ht <- hux(NotPadded = vals, Padded = vals)
number_format(ht) <- '%2.6g'
align(ht)[1:5,] <- 'right'
pad_decimal(ht)[1:4, 2] <- '.'
ht
ht <- huxtable(a = 1:3, b = 3:1)
ht2 <- set_pad_decimal(ht, '.')
pad_decimal(ht2)
ht3 <- set_pad_decimal(ht, 1:2, 1, '.')
pad_decimal(ht3)
ht4 <- set_pad_decimal(ht, 1:2, 1:2, c('.', NA), byrow = TRUE)
pad_decimal(ht4)
ht5 <- set_pad_decimal(ht, where(ht == 1), '.')
pad_decimal(ht5)