Skip to contents

Attaches (set_*) or retrieves (get_*) a "numfmt" attribute to/from a data matrix within a procr_table subtable, describing how its values should be rounded and displayed. Purely descriptive metadata; not used in any calculation, but can be picked up by downstream export/print functions (see to_gt()).

Usage

set_data_numfmt(
  tab,
  ...,
  digits,
  dec_mark,
  sep_mark,
  data = "main",
  subtable = NULL
)

get_data_numfmt(tab, data = "main", subtable = NULL)

Arguments

tab

A procr_table object.

...

Not used for values, forces later arguments to bind by name.

digits

Integer scalar. Number of decimal places to display. Defaults to 0L.

dec_mark

Character scalar. Decimal mark. Defaults to getOption("OutDec"), i.e. the session's configured output decimal mark.

sep_mark

Character scalar. Thousands separator character. Defaults to "\u202F" (narrow non-breaking space) to avoid line wrapping mid-number.

data

Character scalar. Name of the data matrix to attach the format to (e.g. "main", "se"). Defaults to "main".

subtable

Reference to the subtable within tab containing data. Can be NULL (default) if only one subtable exists, else either a character scalar reference to the subtable name or a numeric scalar reference to its position.

Value

set_* returns the modified procr_table object. get_* returns a named list with elements digits, dec_mark, sep_mark, or NULL if no format is set.

See also

set_data_unit() and get_data_unit() to set/get a unit label.

Examples

if (FALSE) { # \dontrun{
  tab <- set_data_numfmt(tab, digits = 2L)
  get_data_numfmt(tab)
} # }