dot-sprintf_dp: Replaces decimal points in sprintf output.

.sprintf_dpR Documentation

Replaces decimal points in sprintf output.

Description

'sprintf' will respect decimal point conventions only if you switch locale. This is unwieldy and not in line with 'format'. This wrapper around 'sprintf' replaces decimal points with a 'sep' character of your choice, sensible choices for which are ',' or 'UTF8+00B7'. It will not try and replace things that are not syntactially numbers.

Usage

.sprintf_dp(fmt, ..., sep = getOption("OutDec", "."))

Arguments

fmt

a sprintf format string

...

Arguments passed on to base::sprintf

sep

a character to use a decimal point.

Value

the formatted string with decimal points as specified

Examples

try({
.sprintf_dp("%1.2f",1:3/3, sep="\u00B7")
.sprintf_dp("%1.2f-%1.2f", 1:3/3, 1:3, sep="\u00B7")
.sprintf_dp("%s %1.2f-%1.2f", "A.1.2", 1:3/3, 1:3, sep="\u00B7")
})

terminological/ggrrr documentation built on June 15, 2024, 6:35 a.m.