Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

align

Set the horizontal alignment of cell content


Description

Values may be "left", "center", "right", NA or a single character. If value is a single character (e.g. a decimal point), then the cell is aligned on this character.

Usage

align(ht)
align(ht) <- value
set_align(ht, row, col, value )
map_align(ht, row, col, fn)

Arguments

ht

A huxtable.

row

A row specifier. See rowspecs for details.

col

An optional column specifier.

fn

A mapping function. See mapping-functions for details.

value

A character vector or matrix.

Set to NA to reset to the default, which is "left".

Details

Neither HTML nor LaTeX currently possess reliable ways of aligning cells on a decimal point. Huxtable does this by padding with spaces. This may work better if you use a fixed-width font.

Value

align() returns the align property. set_align() returns the modified huxtable.

Examples

numbers <- c(1, 1.5, 1.03, 10, 10.01)
number_hux <- as_hux(matrix(numbers, 5, 4))
number_format(number_hux) <- "%.4g"

number_hux <- map_align(number_hux,
      by_cols("left", "center", "right", "."))

alignments <- c("left", "centre", "right", "decimal (.)")
number_hux <- rbind(
        alignments,
        number_hux
      )
number_hux

huxtable

Easily Create and Style Tables for LaTeX, HTML and Other Formats

v5.3.0
MIT + file LICENSE
Authors
David Hugh-Jones [aut, cre]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.