Using sprintf flexibly format numbers as character strings
encoded for parsing into R expressions or using LaTeX or markdown
notation.
character as in sprintf().
as in sprintf().
character If NULL or NA no substitution is
attempted and the value returned by sprintf() is returned as is.
numeric The value of the estimate.
integer Number of digits to which numeric values are formatted.
character One of "e", "f" or "g" for exponential, fixed, or significant digits formatting.
character One of "expression", "latex", "tex", "text", "tikz", "markdown".
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.
sprintf_dm("%2.3f", 2.34)
#> [1] "2.340"
sprintf_dm("%2.3f", 2.34, decimal.mark = ",")
#> [1] "2,340"
value2char(2.34)
#> [1] "\"2.3\""
value2char(2.34, digits = 3, format = "g")
#> [1] "\"2.34\""
value2char(2.34, digits = 3, format = "f")
#> [1] "\"2.340\""
value2char(2.34, output.type = "text")
#> [1] "2.3"
value2char(2.34, output.type = "text", format = "f")
#> [1] "2.34"
value2char(2.34, output.type = "text", format = "g")
#> [1] "2.3"