lt: Create a Table Specification

View source: R/lt.R

ltR Documentation

Create a Table Specification

Description

Entry point of the lightweight grammar of tables. Returns an object (a list) that records the data plus a list of table-modifying operations. The object is rendered to HTML by format() (called automatically by the print method).

Usage

lt(data, ...)

## Default S3 method:
lt(data, auto_format = TRUE, auto_label = TRUE, ...)

Arguments

data

A data frame (or anything coercible to one).

...

Arguments passed to methods.

auto_format

Whether to automatically format numeric columns (rounding, thousand separators, percentage detection). Set to FALSE to disable for the whole table; use lt_format() on specific columns to disable selectively.

auto_label

Whether to automatically clean column names for display by replacing separators (. and ⁠_⁠) with spaces. Set to FALSE to show raw column names.

Value

A table object that can be piped into ⁠lt_*()⁠ functions.

HTML in cells

By default all cell values and text (titles, labels, footnotes, ...) are HTML-escaped, so special characters like <, >, and & render as literal text. To emit content as raw HTML instead:

  • For body cells, mark whole columns with lt_html().

  • For a title, subtitle, column label, spanner, footnote, or note, wrap the text in I(). For example, lt_header(x, I("<b>Report</b>")) renders the title as raw HTML, while lt_header(x, "<b>Report</b>") shows the literal ⁠<b>⁠ tags.

Interactivity

When a cell value has been formatted (e.g., by auto-formatting or lt_format()), the original value is stored in the cell's title attribute and shown as a tooltip on hover. Additionally:

  • Alt + Click on a table toggles display of all raw values in that table.

  • Alt + Double-Click on a table toggles raw values globally (all tables on the page).

Raw values are shown as (value) after the formatted text, highlighted with a light yellow background.

Examples

lt(head(mtcars[, 1:4]))

lt documentation built on July 10, 2026, 1:09 a.m.