lt_format: Format Numeric Columns

View source: R/tab.R

lt_formatR Documentation

Format Numeric Columns

Description

Control the number of decimal places and thousands separator for numeric columns. Columns passed to this function are excluded from automatic formatting (see the auto_format argument of lt()). To disable auto-format for a column without otherwise changing its display, call lt_format(x, ~col) with no other arguments.

Usage

lt_format(
  x,
  columns,
  decimals = NULL,
  big_mark = NULL,
  percent = NULL,
  prefix = NULL,
  suffix = NULL
)

Arguments

x

An lt() object.

columns

Character or integer vector of columns (or a one-sided formula).

decimals

Number of decimal places (default NULL means no change).

big_mark

Thousands separator (e.g., ","). NULL or "" means none.

percent

If TRUE, multiply values by 100 and append "%". If "%", only append "%" without multiplying (for values already in percent scale).

prefix

String prepended to each formatted value (e.g., "$").

suffix

String appended to each formatted value (e.g., " kg").

Value

x with the formatting recorded.

Examples

lt(head(mtcars)) |> lt_format(~ mpg + wt, decimals = 1, big_mark = ",")
d = data.frame(Item = c("A", "B"), Price = c(1234.5, 678.9))
lt(d) |> lt_format(~ Price, decimals = 2, big_mark = ",", prefix = "$")

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