Skip to contents

This function removes repeating trailing zeroes and adds blank white space to align at the decimal point.

Usage

fmt_pad_num(gt_object, columns, sep = ".", nsmall = 2, pad0 = FALSE)

Arguments

gt_object

An existing gt table object of class gt_tbl

columns

The columns to format. Can either be a series of column names provided in c(), a vector of column indices, or a helper function focused on selections. The select helper functions are: starts_with(), ends_with(), contains(), matches(), one_of(), num_range(), and everything().

sep

A character for the separator, typically "." or ","

nsmall

The max number of decimal places to round at/display

pad0

A logical, indicating whether to pad the values with trailing zeros.

Value

An object of class gt_tbl.

Figures

Function ID

2-2

Examples

library(gt)
padded_tab <- data.frame(numbers = c(1.2345, 12.345, 123.45, 1234.5, 12345)) %>%
  gt() %>%
  fmt_pad_num(columns = numbers, nsmall = 4)