number-formatting: Format numbers using 'scales::number()'-type functions

number-formattingR Documentation

Format numbers using scales::number()-type functions

Description

These functions extend the number-type formatting functions, with nice printing of negative numbers, optional replacement of missing values, and vectorised formatting options.

Usage

nmbr(
  x,
  accuracy = 1,
  scale = 1,
  prefix = "",
  suffix = "",
  big.mark = "< >",
  decimal.mark = ".",
  bold = FALSE,
  italic = FALSE,
  html = FALSE,
  na = NA_character_,
  ...
)

prct(
  x,
  percent = "%",
  accuracy = 1,
  prefix = "",
  big.mark = "< >",
  decimal.mark = ".",
  bold = FALSE,
  italic = FALSE,
  html = FALSE,
  na = NA_character_,
  ...
)

cmma(
  x,
  comma = ",",
  accuracy = 1,
  scale = 1,
  prefix = "",
  suffix = "",
  decimal.mark = ".",
  bold = FALSE,
  italic = FALSE,
  html = FALSE,
  na = NA_character_,
  ...
)

dllr(
  x,
  dollar = "$",
  accuracy = 1,
  scale = 1,
  suffix = "",
  big.mark = "< >",
  decimal.mark = ".",
  bold = FALSE,
  italic = FALSE,
  html = FALSE,
  na = NA_character_,
  ...
)

pval(
  x,
  accuracy = 1e-04,
  min_p = accuracy,
  add_p = FALSE,
  decimal.mark = ".",
  html = FALSE,
  na = NA_character_,
  ...
)

create_nmbr(
  accuracy = 1,
  scale = 1,
  prefix = "",
  suffix = "",
  big.mark = "< >",
  decimal.mark = ".",
  html = FALSE,
  na = NA_character_,
  ...
)

Arguments

x

Numeric vector to format

accuracy, scale, prefix, suffix, big.mark, decimal.mark, ...

As in number. If a vector is supplied, will be applied element-wise to x (and must have the same length as x).

bold, italic

Logical scalar or vector (of the same length as x); which (if any) elements of x should be printed in bold or italic face.

html

Logical scalar. Whether to include formatting marks (minus signs and narrow spaces between digits) as HTML strings (TRUE) or unicode (FALSE).

na

String scalar, replacement to use for missing values in x.

percent, comma, dollar

String scalar to use for the specific formatting method (percent sign, comma separator, dollar sign, etc).

min_p

Numeric scalar. The smallest p-value to print; values smaller than this will be printed as "<`min_p`".

add_p

Logical scalar. Should ⁠p=⁠ be included before formatted p-values?

Value

For create_nmbr(), a function with the same arguments as nmbr(); for other functions a character string applying the specified formatting rules to x.


uo-cmor/formattr documentation built on Sept. 13, 2023, 10:46 p.m.