sprintf_dm: Format numeric values as strings

View source: R/utilities-labels.R

sprintf_dmR Documentation

Format numeric values as strings

Description

Using sprintf flexibly format numbers as character strings encoded for parsing into R expressions or using LaTeX or markdown notation.

Usage

sprintf_dm(fmt, ..., decimal.mark = getOption("OutDec", default = "."))

value2char(
  value,
  digits = Inf,
  format = "g",
  output.type = "expression",
  decimal.mark = getOption("OutDec", default = ".")
)

Arguments

fmt

character as in sprintf().

...

as in sprintf().

decimal.mark

character If NULL or NA no substitution is attempted and the value returned by sprintf() is returned as is.

value

numeric The value of the estimate.

digits

integer Number of digits to which numeric values are formatted.

format

character One of "e", "f" or "g" for exponential, fixed, or significant digits formatting.

output.type

character One of "expression", "latex", "tex", "text", "tikz", "markdown".

Details

These functions are used to format the character strings returned, which can be used as labels in plots. Encoding used for the formatting is selected by the argument passed to output.type, thus, supporting different R graphic devices.

See Also

sprintf

Examples


sprintf_dm("%2.3f", 2.34)
sprintf_dm("%2.3f", 2.34, decimal.mark = ",")


value2char(2.34)
value2char(2.34, digits = 3, format = "g")
value2char(2.34, digits = 3, format = "f")
value2char(2.34, output.type = "text")
value2char(2.34, output.type = "text", format = "f")
value2char(2.34, output.type = "text", format = "g")


ggpmisc documentation built on June 28, 2024, 1:07 a.m.