pad_decimal

0th

Percentile

Decimal padding

Functions to get or set the decimal padding property of huxtable table cells.

Usage
pad_decimal(ht)
pad_decimal(ht) <- value
set_pad_decimal(ht, row, col, value, byrow = FALSE)
Arguments
ht

A huxtable.

value

A vector of single characters. NA is the default of no padding. 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.

Details

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'.

Value

For pad_decimal, the pad_decimal attribute. For set_pad_decimal, the ht object.

Aliases
  • pad_decimal
  • pad_decimal<-
  • set_pad_decimal
  • pad_decimal.huxtable
  • pad_decimal<-.huxtable
Examples
# 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)
# }
Documentation reproduced from package huxtable, version 1.2.0, License: MIT + file LICENSE

Community examples

Looks like there are no examples yet.