
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)
A huxtable.
A vector of single characters. NA
is the default of no padding. Set to NA
to reset to the default.
A row specifier. See rowspecs
for details.
An optional column specifier.
If TRUE
, fill in values by row rather than by column.
For pad_decimal
, the pad_decimal
attribute.
For set_pad_decimal
, the ht
object.
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'
.
# NOT RUN {
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)
# }
Run the code above in your browser using DataLab